Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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
Php Jquery停止加载和清除间隔_Php_Jquery_Clearinterval - Fatal编程技术网

Php Jquery停止加载和清除间隔

Php Jquery停止加载和清除间隔,php,jquery,clearinterval,Php,Jquery,Clearinterval,我使用jquery加载一个外部页面,并将其显示在名为View的DIV中 我有两个按钮去和停止 这正在工作,但单击“停止”可能需要几秒钟。 有没有办法让它立刻停止 $("#Go").click(function () { $("#view").load("test.php"); refreshId = setInterval(function() { $("#view").load("test.php"); }, 1000); }); $("#Stop").cl

我使用jquery加载一个外部页面,并将其显示在名为View的DIV中

我有两个按钮去和停止

这正在工作,但单击“停止”可能需要几秒钟。 有没有办法让它立刻停止

$("#Go").click(function () { 
    $("#view").load("test.php");
    refreshId = setInterval(function() { 
    $("#view").load("test.php"); }, 1000);  
});


$("#Stop").click(function () { 
    clearInterval(refreshId); $("#view").stop(); 
    $.ajax({ url : 'new.php' });
} });
谢谢:)

您可以尝试:

var xhr = $.ajax({
    type: "POST",
    url: "test.php",
    data: "name=John&location=Boston",
    success: function(msg){
      $("#view").html(msg);
    }
});
停止通话:

//kill the request
xhr.abort()

停止将数据提交到其他页面。