files/en-us/web/api/xmlhttprequest/index.md
{{APIRef("XMLHttpRequest API")}} {{AvailableInWorkers("window_and_worker_except_service")}}
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.
{{InheritanceDiagram}}
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 {{domxref("EventSource")}} interface. For full-duplex communication, WebSockets may be a better choice.
XMLHttpRequest. It must be called before any other method calls.This interface also inherits properties of {{domxref("XMLHttpRequestEventTarget")}} and of {{domxref("EventTarget")}}.
{{domxref("XMLHttpRequest.readyState")}} {{ReadOnlyInline}}
{{domxref("XMLHttpRequest.response")}} {{ReadOnlyInline}}
{{domxref("XMLHttpRequest.responseText")}} {{ReadOnlyInline}}
null if the request was unsuccessful or has not yet been sent.{{domxref("XMLHttpRequest.responseType")}}
{{domxref("XMLHttpRequest.responseURL")}} {{ReadOnlyInline}}
{{domxref("XMLHttpRequest.responseXML")}} {{ReadOnlyInline}}
null if the request was unsuccessful, has not yet been sent, or cannot be parsed as XML or HTML. Not available in Web Workers.{{domxref("XMLHttpRequest.status")}} {{ReadOnlyInline}}
{{domxref("XMLHttpRequest.statusText")}} {{ReadOnlyInline}}
: Returns a string containing the response string returned by the HTTP server. Unlike {{domxref("XMLHttpRequest.status")}}, this includes the entire text of the response message ("OK", for example).
[!NOTE] According to the HTTP/2 specification {{RFC(7540, "Response Pseudo-Header Fields", "8.1.2.4")}}, HTTP/2 does not define a way to carry the version or reason phrase that is included in an HTTP/1.1 status line.
{{domxref("XMLHttpRequest.timeout")}}
{{domxref("XMLHttpRequest.upload")}} {{ReadOnlyInline}}
{{domxref("XMLHttpRequest.withCredentials")}}
true if cross-site Access-Control requests should be made using credentials such as cookies or authorization headers; otherwise false.XMLHttpRequest.mozAnon {{ReadOnlyInline}} {{Non-standard_Inline}}
XMLHttpRequest.mozSystem {{ReadOnlyInline}} {{Non-standard_Inline}}
null if no response has been received.null if either the response has not yet been received or the header doesn't exist in the response.XMLHttpRequest call, to initiate private state token operations.setRequestHeader() after {{domxref("XMLHttpRequest.open", "open()")}}, but before {{domxref("XMLHttpRequest.send", "send()")}}.This interface also inherits events of {{domxref("XMLHttpRequestEventTarget")}}.
onreadystatechange event handler property.{{Specifications}}
{{Compat}}