Edit in GitHubLog an issue

window.XMLHttpRequest

XMLHttpRequest()#

The constructor initializes an XMLHttpRequest. It must be called before any other method calls.

readyState ⇒ int#

Read only Returns an unsigned short, the state of the request.

Returns: int - returns the state of the XMLHttpRequest client.

responseText ⇒ string#

Read only Returns a DOMString that contains the response to the request as text, or null if the request was unsuccessful or has not yet been sent.

Returns: string - returns the received text response.

responseXML ⇒ object#

Read only Returns the XML document that supports W3C DOM level2 specification. The XML document is constructed with received bytes using XMLHttpRequest.

Returns: object - returns the XML document response.
Throws:

  • DOMException if responseType is not the empty string or "document".

response ⇒ string | ArrayBuffer | Blob | Object#

Read only Returns the response from the server in the type specified by responseType. Only valid after the load event fires.

Returns: string | ArrayBuffer | Blob | Object - returns an ArrayBuffer, Blob, Document, JavaScript object, or a DOMString, depending on the value of; XMLHttpRequest.responseType that contains the response entity body.

status ⇒ string#

Read only Returns: string - returns the HTTP status code received from the server.

statusText ⇒ string#

Read only Returns: string - returns the response's status message with regard to the HTTP status code received from the server.

timeout#

The number of milliseconds a request can take before automatically being terminated. The default value is 0, which means there is no timeout.

timeout#

Terminates a request and a timeout event will be dispatched after the given time has passed.

Throws:

  • DOMException if called for synchronous request.
ParamTypeDescription
valuenumbernumber of milliseconds a request can take automatically being terminated.

responseType ⇒ string#

Returns: string - returns a string taken from the XMLHttpRequestResponseType enum which specifies; what type of data the response contains.

responseType#

ParamTypeDescription
valuestringA string indicating the type of data contained in the response. This should be "arraybuffer", "blob", "document", "json" or "text".

withCredentials#

Indicates whether to send cookies on a HTTP request. When the value is set to true, XMLHttpRequest sends cookies. Otherwise, cookies are not sent.

withCredentials#

Throws:

  • DOMException when set if state is not unsent or opened.
ParamTypeDefaultDescription
[value]Booleantruewhether to send cookies on a HTTP request.

upload ⇒ XMLHttpRequestEventUpload#

Read only If XMLHttpRequest has data in the body to upload, upload related event will be notified via XMLHttpRequest.upload.

Returns: XMLHttpRequestEventUpload - returns XMLHttpRequestEventUpload object.

abort()#

Aborts the request if it has already been sent.

getAllResponseHeaders()#

Read only Returns sorted and combined response’s header list. Each header field is defined by a group of [lower cased name]": "[value]"\r\n". Combined value is separated by ", ".

Returns: string - returns response’s header list.

getResponseHeader(name)#

Read only Returns the matching value of the given field name in response's header. The search key value is case-insensitive

Returns: string - returns the value of the given name in response's header list.

ParamTypeDescription
namestringThe name to search in response's header list.

open(method, url, [async], [user], [password])#

Initializes a request. This method is to be used from JavaScript code; to initialize a request from native code, use openRequest() instead. Self-signed certificates are not currently supported for HTTPS connections.

ParamTypeDefaultDescription
methodstringThe HTTP request method to use, such as "GET", "POST", "PUT", "DELETE", etc. Ignored for non-HTTP(S) URLs.
urlstringA DOMString representing the URL to send the request to.
[async]booleantrueAn optional Boolean parameter, defaulting to true, indicating whether or not to perform the operation asynchronously. If this value is false, the send() method does not return until the response is received. If true, notification of a completed transaction is provided using event listeners. This must be true if the multipart attribute is true, or an exception will be thrown.
[user]stringnullThe optional user name to use for authentication purposes; by default, this is the null value.
[password]stringnullThe optional password to use for authentication purposes; by default, this is the null value.

overrideMimeType(mimetype)#

Use a MIME type other than the one provided by the server when interpreting the data being transferred in a request. If parsing the MIME type fails, "application/octet-stream" will be used to interpret the data.

Throws:

  • DOMException if state is loading or done
ParamTypeDescription
mimetypestringMIME type Since Only UTF-8 is supported for charset of text encoding, MIME type’s parameters "charset" with other values than 'UTF-8' is not valid.

setRequestHeader(header, data)#

Sets the value of an HTTP request header. You must call setRequestHeader()after open(), but before send().

ParamTypeDescription
headerstringThe name of the header whose value is to be set.
datastringThe value to set as the body of the header.

send([data])#

Sends the request. If the request is asynchronous (which is the default), this method returns as soon as the request is sent.

ParamTypeDefaultDescription
[data]*``A body of data to be sent in the XHR request. This can be: A Document, in which case it is serialized before being sent. A BodyInit, which as per the Fetch spec can be a Blob, BufferSource, FormData, URLSearchParams, ReadableStream, or USVString object. If no value is specified for the body, a default value of null is used. The best way to send binary content (e.g. in file uploads) is by using an ArrayBufferView or Blob in conjunction with the send() method. There is a caveat for sending a FormData object. The files in the FormData object are being read after calling this method. To ensure uploading files as-is, the file contents or files shouldn't be changed until uploading files to the server is done. @see XMLHttpRequest.upload. If there is a problem during reading files, the XMLHttpRequest transaction initiated by this method can be aborted with an error event fired.
Copyright © 2021 Adobe. All rights reserved.