XMLHttpRequest API
Object: XMLHttpRequest
The XMLHttpRequest object enables you to transfer data to and from the server without reloading or replacing the current document.
To make an HTTP request, you create the instance of the object, open a URL, and send the request. The HTTP status code of the result, as well as the result document are available in the request object afterwards.
Because it allows you to communicate with a server in the background, the XMLHttpRequest object enables you to create extremely dynamic documents.
XMLHttpRequest properties
|
Property name |
Type |
Description |
Status |
Support level |
Availability |
|---|---|---|---|---|---|
|
readyState |
unsigned short |
Returns the status of the server's response. Each time the readyState property changes, the onreadystatechange function will be executed. |
read only |
4.6 or later |
|
|
responseText |
DOMString |
Returns the response text entity body. This might return only a fragment of the entity body, if the request response is still in the loading state. |
read only |
4.6 or later |
|
|
responseXML |
DOMString |
Returns the XML response entity body. This might return only a fragment of the entity body, if the request response is still in the loading state. |
read only |
4.6 or later |
|
|
status |
unsigned short |
Returns the HTTP status code sent by the server, or, if no status code is available, throws an INVALID_STATE_ERR exception. |
read only |
4.6 or later |
|
|
statusText |
DOMString |
Returns the HTTP status text sent by the server, or, if no status text is available, throws an INVALID_STATE_ERR exception. |
read only |
4.6 or later |
XMLHttpRequest event handlers
XMLHttpRequest methods
|
Method name |
Description |
Support level |
Availability |
|---|---|---|---|
|
abort() |
Stops the current request in progress, which sets the value for XMLHttpRequest.readyState to DONE |
4.6 or later |
|
|
addEventListener() |
Adds an EventListener object to a set of event listeners for the given node. |
4.6 or later |
|
|
dispatchEvent() |
Dispatches an Event object created by Document.createEvent(). |
4.6 or later |
|
|
getAllResponseHeaders() |
Returns a complete set of headers and their values. |
4.6 or later |
|
|
getResponseHeader() |
Returns the value of the given header. |
4.6 or later |
|
|
open() |
Assigns the HTTP method and destination URL, and possibly some additional parameters, for a pending request. |
4.6 or later |
|
|
removeEventListener() |
Removes an event listener from an EventTarget. |
4.6 or later |
|
|
send() |
Sends the request to the URL specified by XMLHttpRequest.open(). |
4.6 or later |
|
|
setRequestHeader() |
Specifies the value of a header to be sent with the request. |
4.6 or later |