After a request is sent, the client cannot determine when the request will be completed. Therefore, an event mechanism is required to capture the Request status. The XMLHTTPRequest object provides the onreadystatechange event to implement this function. This is similar to the callback function. Onreadystatechange event can be used to specify an event handler to process the execution results of the XMLHTTPRequest object, such as ajaxobj = createajaxobject (); var url = "/mytodoes/fetchtext? Id = "+ ID; ajaxobj. open ("get", URL, true); ajaxobj. onreadystatechange = changetabcallback; ajaxobj. send (null); The onreadystatechange event is triggered when the readystate attribute changes. The value of readystate indicates the status of the current request. Program You can perform different processing based on this value. Readystate can be set to 0: not initialized, 1: Loading, 2: Loading, 3: processing, and 4: processing. Once the value of the readystate attribute is changed to 4, you can access the response data returned by the server. The value of readystate is usually processed only when the request is completed, for example, function changetabcallback () {If (ajaxobj. readystate = 4) {// next verification} status stores the HTTP request response returned by the server Code It indicates the request processing result. The meaning of common response code is as follows: Right. In Ajax development, the most common response code is 200. The Code is as follows: function changetabcallback () {If (ajaxobj. readystate = 4) {If (ajaxobj. status = 200) {// The server returns the correct data, start Response Processing} HTTP status code meaning 200 request successful 202 request accepted but not completed 400 Error request 404 request resource not found 500 Internal Server Error