weixin_33728268 2011-12-12 11:35 采纳率: 0%
浏览 19

用XHR取消PHP脚本?

I have with your help:

function send(){
  $.get("/site/send.php", function(data){
    alert(data);
  }
}

In site/send.php I have:

for($=0;$i++;$i<1000)
    sleep(1);
}
    echo "OK";

Next I have in my js file:

send();
$("#click").click(function(){
  window.stop(); // this cancel XHR
  $.get("/site/reset.php", function(data){
    alert(data);
  }
})

and in reset.php:

echo "RESET";

window.stop(); cancel my XHR but this still doesnt working OK. i cancel XHR, but still i must wait for sleep(1000) in function send(). This doesnt return anything, but still continues to execute. Only if sleep is > 1000 then /site/reset.php begins to execute.

how can i in this example cancel PHP function?

is possible check in PHP file check if XHR still isset?

  • 写回答

3条回答 默认 最新

  • weixin_33701564 2011-12-12 11:40
    关注
    $("#click").click(function(){
      //window.stop(); 
      return false;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法