XMLHttpRequest

XMLHttpRequest (XHR) objects are used to interact with servers.

MDN Reference

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed interface ReadyState

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The XMLHttpRequest.readyState property returns the state an XMLHttpRequest client is in.

Link copied to clipboard

The XMLHttpRequest response property returns the response's body content as an ArrayBuffer, a Blob, a Document, a JavaScript Object, or a string, depending on the value of the request's XMLHttpRequest.responseType property.

Link copied to clipboard

The read-only XMLHttpRequest property responseText returns the text received from a server following a request being sent.

Link copied to clipboard

The XMLHttpRequest property responseType is an enumerated string value specifying the type of data contained in the response.

Link copied to clipboard

The read-only XMLHttpRequest.responseURL property returns the serialized URL of the response or the empty string if the URL is null.

Link copied to clipboard

The XMLHttpRequest.responseXML read-only property returns a Document containing the HTML or XML retrieved by the request; or null if the request was unsuccessful, has not yet been sent, or if the data can't be parsed as XML or HTML.

Link copied to clipboard

The read-only XMLHttpRequest.status property returns the numerical HTTP status code of the XMLHttpRequest's response.

Link copied to clipboard

The read-only XMLHttpRequest.statusText property returns a string containing the response's status message as returned by the HTTP server.

Link copied to clipboard

The XMLHttpRequest.timeout property is an unsigned long representing the number of milliseconds a request can take before automatically being terminated.

Link copied to clipboard
Link copied to clipboard

The XMLHttpRequest upload property returns an XMLHttpRequestUpload object that can be observed to monitor an upload's progress.

Link copied to clipboard

The XMLHttpRequest.withCredentials property is a boolean value that indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies, authentication headers or TLS client certificates.

Functions

Link copied to clipboard
fun abort()

The XMLHttpRequest.abort() method aborts the request if it has already been sent.

Link copied to clipboard
Link copied to clipboard

The XMLHttpRequest method getAllResponseHeaders() returns all the response headers, separated by CRLF, as a string, or returns null if no response has been received.

Link copied to clipboard

The XMLHttpRequest method getResponseHeader() returns the string containing the text of a particular header's value.

Link copied to clipboard
fun open(method: RequestMethod, url: String)

The XMLHttpRequest method open() initializes a newly-created request, or re-initializes an existing one.

fun open(method: RequestMethod, url: URL)
fun open(method: RequestMethod, url: String, async: Boolean, username: String? = definedExternally, password: String? = definedExternally)
fun open(method: RequestMethod, url: URL, async: Boolean, username: String? = definedExternally, password: String? = definedExternally)
Link copied to clipboard

The XMLHttpRequest method overrideMimeType() specifies a MIME type other than the one provided by the server to be used instead when interpreting the data being transferred in a request.

Link copied to clipboard
fun send(body: BufferSource?)
fun send(body: String?)
fun send(body: Blob?)
fun send(body: FormData?)
fun send(body: URLSearchParams?)

fun send(body: Document? = definedExternally)

The XMLHttpRequest method send() sends the request to the server.

Link copied to clipboard
fun setRequestHeader(name: String, value: String)

The XMLHttpRequest method setRequestHeader() sets the value of an HTTP request header.

Link copied to clipboard