Five states of page load readyState

Five states of page load readyState

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-(Uninitialized) This stage confirms whether the XMLHttpRequest object is created, and is ready to call the open() method for uninitialization. A value of 0 means the object already exists, otherwise the browser will report an error-the object does not exist
1-(load In) In this stage, the XMLHttpRequest object is initialized, that is, the open() method is called, the object state is set according to the parameters (method, url, true), and the send() method is called to start sending the request to the server. The value is 1 means it is Send request
2 to the server-(loading completed) This stage receives the response data from the server. But what you get is only the original data of the server response, and it cannot be used directly on the client. A value of 2 means that all response data has been received and ready for the next stage of data analysis.
3-(Interactive) This stage of analysis The received server-side response data. That is, according to the MIME type returned by the server-side response header, the data is converted into a format that can be accessed through the responseBody, responseText, or responseXML attributes to prepare for the call on the client side. State 3 means that the data is being parsed.
4-(Completed) this stage Confirm that all data has been parsed into a format usable by the client. The analysis has been completed. A value of 4 means that the data has been parsed. The data can be obtained through the corresponding attributes of the XMLHttpRequest object.

  • The life cycle of the XMLHttpRequest object:
    create-initialize request-send request-receive data-parse data-complete

Guess you like

Origin blog.csdn.net/LvJzzZ/article/details/109568762