XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing.
XMLHttpRequest is used heavily in AJAX programming.
Despite its name,
XMLHttpRequest can be used to retrieve any type of data, not just XML.
If your communication needs to involve receiving event data or message data from a server, consider using server-sent events through the
EventSource interface. For full-duplex communication, WebSockets may be a better choice.
The constructor initializes an
XMLHttpRequest. It must be called before any other method calls.
Returns a number representing the state of the request.
Returns a string that contains the response to the request as text, or
nullif the request was unsuccessful or has not yet been sent.
Specifies the type of the response.
Returns the serialized URL of the response or the empty string if the URL is null.
Returns the HTTP response status code of the request.
Returns a string containing the response string returned by the HTTP server. Unlike
XMLHttpRequest.status, this includes the entire text of the response message ("
OK", for example).
Note: According to the HTTP/2 specification RFC 7540, section 22.214.171.124: Response Pseudo-Header Fields, HTTP/2 does not define a way to carry the version or reason phrase that is included in an HTTP/1.1 status line.
The time in milliseconds a request can take before automatically being terminated.
XMLHttpRequestUploadrepresenting the upload process.
Access-Controlrequests should be made using credentials such as cookies or authorization headers; otherwise
The channel used by the object when performing the request.
A boolean. If true, the request will be sent without cookie and authentication headers.
A boolean. If true, the same origin policy will not be enforced on the request.
A boolean. It indicates whether or not the object represents a background service request.
Aborts the request if it has already been sent.
Returns all the response headers, separated by CRLF, as a string, or
nullif no response has been received.
Returns the string containing the text of the specified header, or
nullif either the response has not yet been received or the header doesn't exist in the response.
Initializes a request.
Overrides the MIME type returned by the server.
Sends the request. If the request is asynchronous (which is the default), this method returns as soon as the request is sent.
Fired when a request has been aborted, for example because the program called
XMLHttpRequest.abort(). Also available via the
onabortevent handler property.
Fired when the request encountered an error. Also available via the
onerrorevent handler property.
Fired when an
XMLHttpRequesttransaction completes successfully. Also available via the
onloadevent handler property.
Fired when a request has started to load data. Also available via the
onloadstartevent handler property.
Fired periodically when a request receives more data. Also available via the
onprogressevent handler property.
Fired whenever the
readyStateproperty changes. Also available via the
onreadystatechangeevent handler property.
Fired when progress is terminated due to preset time expiring. Also available via the
ontimeoutevent handler property.
|XMLHttpRequest Standard |
BCD tables only load in the browser