jQuery-我可以从.ajaxStart或.ajaxStop检索(事件,xhr,选项)吗? [英] jquery - Can I retrieve (event, xhr, options) from .ajaxStart or .ajaxStop?

查看:72
本文介绍了jQuery-我可以从.ajaxStart或.ajaxStop检索(事件,xhr,选项)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于 http://api.jquery.com/ajaxComplete/

.ajaxComplete( handler(event, XMLHttpRequest, ajaxOptions) )
.ajaxStart( handler(event) )

据我所知和经验,用于.ajaxStart或.ajaxStop处理程序的XMLHttpRequest和ajaxOptions参数为空.

To my knowledge and experiements, the XMLHttpRequest and ajaxOptions parameters for the handler of .ajaxStart or .ajaxStop are null.

我想在.ajaxStart和.ajaxStop函数内部检索ajaxOptions信息.有可能吗?

I would like to retrieve the ajaxOptions information inside the functions of .ajaxStart and .ajaxStop. Is that possible?

如果我连接.ajaxSend + .ajaxComplete而不是.ajaxStart + .ajaxComplete,将会遇到什么问题.我喜欢这样做的主要原因是.ajaxSend可以访问所有三个参数.

What problems will I have if I hook up with .ajaxSend + .ajaxComplete rather than .ajaxStart + .ajaxComplete. The major reason I like to do so is that .ajaxSend can access all three parameters.

推荐答案

您无法在此处访问它们,因为这些事件是针对请求的活动计数变为0以上并返回的情况,但不是 per -请求,它们用于整体活动.

You can't access them here because these events are for when the active count of requests changes to above 0 and back, but aren't per-request, they're for overall activity.

我认为您追求的是 .ajaxSend()

I think what you're after is .ajaxSend() and .ajaxComplete() which fire per-request and have the requested parameters, for example:

$(document).ajaxSend(function(event, xhr, options) {
  //do start stuff
}).ajaxComplete(function(event, xhr, options) {
  //do end stuff
});

这篇关于jQuery-我可以从.ajaxStart或.ajaxStop检索(事件,xhr,选项)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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