jQuery的$就和readyStates [英] jQuery $.ajax and readyStates

查看:125
本文介绍了jQuery的$就和readyStates的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好 任何人都知道如何调用Ajax的就绪状态在jQuery的$。阿贾克斯的方法? 欢呼声。

Hello Anyone knows how to call the Ajax ready states on the jQuery $.ajax method ? cheers.

推荐答案

$阿贾克斯() 返回XmlHtt prequest对象,所以,如果你的真正的要访问它作为状态的改变,你可以这样做:

$.ajax() returns the XmlHttpRequest object, so if you really want to access it as the state changes, you can do this:

var xhr = $.ajax({ ... });
xhr.onreadystatechange = function() { alert(xhr.readyState); };

但内置的回调应该是你所需要的大多数应用中,特别是成功完整

要做事的要求大火之前,使用 beforeSend ,或者更恰当的大多数情况下,的 .ajaxStart() 和的 .ajaxStop() 事件......比如显示,只要任何阿贾克斯活动是怎么回事加载信息。

To do things before the request fires, use beforeSend, or more appropriately for most cases, the .ajaxStart() and .ajaxStop() events...for example to show a loading message whenever any ajax activity is going on.

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

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