Property
Describe
ReadyState
Represents the state of a XMLHttpRequest object [1]
ResponseText
Contains HTTP-appropriate text content that is received by the client [2]
Responsexml
The DOM object corresponding to the XML content of the server response [3]
Status
Server return HTTP status code [4]
StatusText
The server returns a text message for the status code [5]
Event
Describe
onReadyStateChange
This event is triggered when the ReadyState property changes, and is used to trigger the callback function.
[1]:
State
Name
Describe
0
Uninitialized
Initialization state. The XMLHttpRequest object has been created or has been reset by the Abort () method.
1
Open
The open () method was invoked, but the Send () method was not invoked. The request has not been sent yet.
2
Send
The Send () method has been invoked and the HTTP request has been sent to the WEB server. The response was not received.
3
Receiving
All response headers have been received. The response body began to receive but did not complete.
4
Loaded
The HTTP response has been fully received.
When [2]:readystate=4, ResponseText contains the complete response information.
When readystate=3, ResponseText contains incomplete response information.
When Readystate<3, the ResponseText is an empty string.
[3]: When readystate=4, and the Content-type MIME type of the response head is XML (Text/xml or Application/xml), the attribute has a value and is parsed into an XML document. Other cases are null, including the return of an XML document that is bad or does not complete the response.
[4]: If 200 indicates success, and 404 indicates "NotFound" error. Reading this property when ReadyState is less than 3 results in an exception.
[5]: When the state is 200 it is "OK" and when the state is 404 it is "not Found". As with the Status property, reading this property when ReadyState is less than 3 results in an exception.
Method 1.open method of XMLHttpRequest Object
Description: Develop HTTP method with server interaction, URL address and other request information.
Open (Method,url, async, username, password) for initialization
Return value: Gets an object that contains the Send () method
Method: Must be. Used to specify HTTP request methods that support all HTTP methods, such as Get,post, as specified
URI: The address of the requested server, which is automatically parsed into an absolute address.
Async: The request is asynchronous, true means that you are asynchronous, False indicates synchronization, default is True.
Username,password: You can specify the username and password, respectively, and provide the user name and password required by the HTTP authentication mechanism.
After calling open, the readystate state is 1. 2.send (content) method
Description: Makes a request to the server, and its contents can be DOM objects, input streams, or strings.
After you call the Open method, you can call the Send () method to send the request.
When async=true in Open, the Send () method returns immediately after the call, otherwise it is interrupted until the request returns. 3.abort () method
The method can suspend a HttpRequest request or HttpResponse reception, and set the XMLHttpRequest state to initialize. 4.setRequestHeader (Header,value) method
This method is used to set the header information for the request. This method needs to be invoked after the open method. 5.getResponseHeader () method
Description: Returns all response header information containing HTTP, where the response header includes content such as Content-length,date,uri.
When Readystate>2, this method retrieves the header information for the response. Otherwise, an empty string is returned.
The getAllResponseHeaders () method returns all HttpResponse header information.
knowledge of the XMLHttpRequest object, the focus is on how to use the