0: (Uninitialized) the send( ) method has not yet been invoked.
1: (Loading) the send( ) method has been invoked, request in progress.
2: (Loaded) the send( ) method has completed, entire response received.
3: (Interactive) the response is being parsed.
4: (Completed) the response has been parsed, is ready for harvesting.
0 - (未初始化)还没有调用send()方法
1 - (载入)已调用send()方法,正在发送请求
2 - (载入完成)send()方法执行完成,已经接收到全部响应内容
3 - (交互)正在解析响应内容
4 - (完成)响应内容解析完成,可以在客户端调用了
readyState Status Code |
Status of the XMLHttpRequest Object |
---|---|
(0) UNINITIALIZED |
The object has been created but not initialized. (The open method has not been called.) |
(1) LOADING |
The object has been created, but the send method has not been called. |
(2) LOADED |
The send method has been called, but the status and headers are not yet available. |
(3) INTERACTIVE |
Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available. |
(4) COMPLETED |
All the data has been received, and the complete data is available in the responseBody and responseText properties. |
比如在点完保存以后显示正在保存的状态时应该判断readyState == 2的时候,执行显示的状态