About five state readyState property of the XMLHttpRequest

About five state readyState property of the XMLHttpRequest

(0) uninitialized
at this stage to confirm whether the XMLHttpRequest object creation, and to call the open () method were not ready to initialize. A value of 0 represents the object already exists, otherwise the browser will complain - object does not exist.
(1) Loading
This stage of the XMLHttpRequest object is initialized, i.e., calls the open () method, to complete the setting state of the object according to the parameters (method, url, true). And calls the send () method to start sending requests to the server. It represents a value of 1 is sending a request to the server.
(2) Loading complete
response data receiving server at this stage. But just raw data obtained from the server response, and can not be used directly in the client. 2 indicates the complete unit has received the response data. Data analysis and to prepare for the next stage.
(3) the interaction
of this stage the server parses the received response data. That response header returned by the server converts the data into a MIME type format can responseBody, responseText responseXML property or accessed, the client calls to prepare. 3 shows the state of being parsed data.
(4) complete
this phase confirm that all data has been parsed format available to the client, parse has been completed. 4 shows a data analysis is completed, the data can be obtained by the corresponding property of the XMLHttpRequest object.
Almost and including, the entire life cycle of the XMLHttpRequest object should contain the following stages:

Create - Initialization Request - send a request - receiving data - analysis data - complete

Guess you like

Origin www.cnblogs.com/li923/p/11648955.html