jQuery的阿贾克斯,运行prevent回调 [英] jQuery ajax, Prevent callback from running

查看:87
本文介绍了jQuery的阿贾克斯,运行prevent回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用jQuery的ajaxComplete或ajaxStop特点决定回调是否不被调用?

is it possible to use the ajaxComplete or ajaxStop features of jQuery to decide whether or not the callback gets called?

基本上我希望能够采取基本的错误检查code这是目前大多数我的回调,并将其添加到一种全球性回调。

Essentially I want to be able to take basic error checking code that is currently in most of my callbacks, and add it to a sort of global callback.

推荐答案

排序回答:否

龙答:这两个 ajaxComplete ajaxStop 是jQuery的AJAX事件。不能从发生prevent事件 - 与事件是指没有其他的执行已登记的回调函数。回调被调用无论如何,如果你想要或不。

Long answer: Both ajaxComplete and ajaxStop are jQuery AJAX events. You cannot prevent events from happening - and "event" means nothing else as "execute every callback function that has been registered". Callbacks get called regardless, if you want or not.

您的什么的做的是计划中的回调,使得它的没有的时候一定要求(或不能)满足。实际上,这是你问什么了。如果您编辑您的问题来解释你在做什么确切地,人们可以告诉你如何做到这一点。

What you can do is program your callback so that it does nothing when certain requirements are (or are not) met. In effect this is exactly what you asked for. If you edit your question to explain what you're up to exactly, people can show you how to do it.

这篇关于jQuery的阿贾克斯,运行prevent回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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