Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajquery ajax调用结果301错误永久移动_Jquery_Ajax - Fatal编程技术网

Ajquery ajax调用结果301错误永久移动

Ajquery ajax调用结果301错误永久移动,jquery,ajax,Jquery,Ajax,我的设置是对php文件的jquery ajax调用。如果php处理时间达到大约40秒,jquery就会工作。如果php处理时间更长,ajax调用就会失败 jquery代码: $.ajax({ url: "http://example.com/path/to/folder/phpfile.php", type: "post", success: function(data){ alert("good!"); }, error:functi

我的设置是对php文件的jquery ajax调用。如果php处理时间达到大约40秒,jquery就会工作。如果php处理时间更长,ajax调用就会失败

jquery代码:

$.ajax({
    url: "http://example.com/path/to/folder/phpfile.php",
    type: "post",

    success: function(data){
        alert("good!"); 
    },
    error:function(xhr,status,error){
        alert("failure");
        console.log(status, error);
    }
});
PHP文件:

set_time_limit(0);  // no time limit is imposed
header("HTTP/1.1 200 OK");
sleep(55); //this will trigger error if >40
echo "1";
exit();
.htaccess文件: (这是为了将所有www.example.com调用重定向到

我试过: 1) 在php文件的开头发送200个ok代码 2) 我在php文件中设置了一个时间限制(0),所以它不应该超时。 3) 我使用非永久链接作为php文件的直接地址


什么会导致这种行为?我如何修复它?

为了以后的参考,我设法解决了这个问题

此代码适用于:

header('Cache-Control: no-cache'); 

set_time_limit(0);  // no time limit is imposed

for($i = 1; $i <= 8; $i++) {
   echo "$i<br>";
   sleep(10);
   ob_flush();
   flush();
};
echo "stop";
exit();
header('Cache-Control:no-Cache');
设置时间限制(0);//没有时间限制
对于($i=1;$i)
header('Cache-Control: no-cache'); 

set_time_limit(0);  // no time limit is imposed

for($i = 1; $i <= 8; $i++) {
   echo "$i<br>";
   sleep(10);
   ob_flush();
   flush();
};
echo "stop";
exit();