dongshuzui0335 2013-09-24 13:51
浏览 60

如果服务器响应特定的东西,则运行(JS)函数

On one of my pages I have "tracking.php" that makes a request to another server, and if tracking is sucessful in Firebug Net panel I see the response trackingFinished();

Is there an easy way (built-in function) to accomplish something like this:

If ("tracking.php" responded "trackingFinished();") { *redirect*... }

Javascript? PHP? Anything?

The thing is, this "tracking.php" also creates browser and flash cookies (and then responds with trackingfinished(); when they're created). I had a JS that did something like this:

If ("MyCookie" is created) { *redirect*... }

It worked, but if you had MyCookie in your browser from before, it just redirected before "track.php" had the time to create new cookies, so old cookies didn't get overwritten (which I'm trying to accomplish) before the redirection...

The solution I have in mind is to redirect after trackingFinished(); was responded...

  • 写回答

2条回答 默认 最新

  • duanchouyi6730 2013-09-24 14:05
    关注

    I think the better form in javascript to make request from one page to another, without leaving the first is with the ajax method, and this one jQuery make it so easy, you only have to use the ajax function, and pass a little parameters:

    $.post(url, {parameter1: parameter1value, param2: param2value})
    

    And you can concatenate some actions:

    $.post().done(function(){}).fail(function(){})
    

    And isntead of the ajax, you can use the $.post that is more easy, and use the done and fail method to evaluate the succes of the information recived

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题