7
是否可以中止先前運行的Ajax請求?中止以前運行的Ajax請求
var xhr = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert("Data Saved: " + msg);
}
});
是否可以中止先前運行的Ajax請求?中止以前運行的Ajax請求
var xhr = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert("Data Saved: " + msg);
}
});
嘗試這樣的事情
$(document).ready(function(){
var xhr; // global object
function your_function() {
if(xhr && xhr.readystate != 4){
xhr.abort();
}
xhr = $.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert("Data Saved: " + msg);
}
});
}
});
謝謝,它爲我工作。 –
怎麼樣'如果(XHR){xhr.abort();}'? –
我認爲這是可能的,它是可用的ASP.NET AJAX工具包 – Devesh
感謝所有答案。現在它解決了 –