How to stop Ajax call in jquery
This question already has an answer here:
this probally has more XHR..
Please see this answer:
jquery abort() ajax request before sending another
From the link:
every time you do ajax request, add to array:
requests.push(
$.ajax({
type: 'post',
url: '/test.php',
data: search_data,
success: function(data) {
$('#catalog').html(data);
}
}));
Then, when you want to stop calls.. loop through array and abort all calls..
for(var i = 0; i < requests.length; i++)
requests[i].abort();
Thanks
xhr.abort()会导致客户端停止监听事件,但可能不会阻止服务器处理它。
Provided the code you've pasted is the code you're actually using it's no wonder it doesn't work.
As it states on the site it is just pseudo code to illustrate an example. There is no AJAX request there and nothing to stop (at least nothing large enough to be able to stop)
链接地址: http://www.djcxy.com/p/71928.html上一篇: ajax缓存不工作
下一篇: 如何在jquery中停止Ajax调用