如何停止Ajax请求 [英] How to stop ajax request
本文介绍了如何停止Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery制作Ajax请求
I'm using jquery for making ajax requests
$.ajax(
url: "http://someurl.org",
success: function() { ... }
);
我如何手动停止我的特殊Ajax请求?
How can I manually stop my particular ajax request?
推荐答案
在 $阿贾克斯()
方法返回一个对象,可以用来做:
The $.ajax()
method returns an object that could be used to do that:
var xhr = $.ajax(
url: "http://someurl.org",
success: function() { ... }
);
再后来,当你想停止请求:
and then later when you want to stop the request:
xhr.abort();
这篇关于如何停止Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文