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.
An Event handler that is called whenever the
unsigned short, the state of the request.
DOMStringthat contains the response to the request as text, or
nullif the request was unsuccessful or has not yet been sent.
Is an enumerated value that defines the response type.
Returns the serialized URL of the response or the empty string if the URL is null.
Documentcontaining the response to the request, or
nullif the request was unsuccessful, has not yet been sent, or cannot be parsed as XML or HTML. Not available in workers.
unsigned shortwith the status of the response of the request.
unsigned longrepresenting the number of milliseconds a request can take before automatically being terminated.
Is an Event handler that is called whenever the request times out.
XMLHttpRequestUpload, representing the upload process.
Is a boolean value that indicates whether or not cross-site
Access-Controlrequests should be made using credentials such as cookies or authorization headers.
The channel used by the object when performing the request.
Is a boolean. If true, the request will be sent without cookie and authentication headers.
Is a boolean. If true, the same origin policy will not be enforced on the request.
Is a boolean. It indicates whether or not the object represents a background service request.
onreadystatechange as a property of the
XMLHttpRequest instance is supported in all browsers.
Since then, a number of additional
on* event handler properties have been implemented in various browsers (
onprogress, etc.). See Using XMLHttpRequest.
More recent browsers, including Firefox, also support listening to the
XMLHttpRequest events via standard
addEventListener() APIs in addition to setting
on* properties to a handler function.
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.
Sets the value of an HTTP request header. You must call
open(), but before
Fired when the request encountered an error. Also available via the
Fired when a request has started to load data. Also available via the
Fired periodically when a request receives more data. Also available via the
Fired when progress is terminated due to preset time expiring. Also available via the
|XMLHttpRequest Standard (XMLHttpRequest)|
BCD tables only load in the browser