停止ajaxStart jQuery的Ajax请求 [英] Stop jquery ajax request in ajaxStart

查看:174
本文介绍了停止ajaxStart jQuery的Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能从jQuery的全球事件中停止当前的Ajax请求ajaxStart?

Is it possible to stop the current ajax request from within the jquery global event ajaxStart?

推荐答案

.ajaxStart 没有访问XHR对象。 .ajaxSend 然而呢。您可以阻止它。我不知道你为什么会想这样做,但请记住,这是一个全球性的AJAX事件 - 所以这有效地阻止所有的Ajax请求(或​​至少是那些不具备全球:假标记)。

.ajaxStart doesn't have access to the xhr object. .ajaxSend does, however. You can stop it there. I don't know why you would want to do this, but remember that this is a global ajax event -- so this effectively stops all ajax requests(or at least those that don't have the global:false flag).

$('some-object').ajaxSend(function(e, xhr) {
    xhr.abort();
});

这篇关于停止ajaxStart jQuery的Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆