Ajax readystate 5种状态

Status 说明
0(Uninitialized) XMLHttpRequest 对象已经创建,但没调用 open 方法。
1(Loading) 调用 open 方法,但没调用 send 方法。(尚未发送请求)
2(Loaded) 已调用 send 方法,已经接收到全部响应内容,但还不能在客户端使用。
3(Interactive) 可拿到部分数据,可通过responseBody、responseText或responseXML 进行解析,所以对于响应信息的体积比较大的情况下就可以分批处理。
(PS: Firefox 和 Chrome 都可以通过多次拿到响应的数据,而IE 则只调用1次。IE6 和 IE7 不支持 readyState 为 3 的状态。
Microsoft's documentation for XMLHttpRequest explicitly states that it is an error to query ‘responseText’ in this state。it is safest to ignore any value of readyState other than 4.)
4(Completed) 已经接收到全部数据。通过 xhr.getAllResponseHeaders() 等方法提取数据。
posted @ 2016-05-27 16:56  zhengming  阅读(216)  评论(0编辑  收藏  举报