class XMLHttpRequest extends EventTarget
XMLHttpRequest is a JavaScript object that was designed by Microsoft and adopted by Mozilla, Apple, and Google. It's now being standardized in the W3C. It provides an easy way to retrieve data from a URL without having to do a full page refresh. A Web page can update just a part of the 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, and it supports protocols other than HTTP (including file and ftp).
MDN
- Annotations
- @JSType() @native() @JSGlobal()
- Alphabetic
- By Inheritance
- XMLHttpRequest
- EventTarget
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new XMLHttpRequest()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
abort(): Unit
Aborts the request if it has already been sent.
Aborts the request if it has already been sent.
MDN
-
def
addEventListener[T <: Event](type: String, listener: Function1[T, _], options: EventListenerOptions): Unit
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on.
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
This implementation accepts a settings object of type EventListenerOptions.
MDN
- Definition Classes
- EventTarget
-
def
addEventListener[T <: Event](type: String, listener: Function1[T, _], useCapture: Boolean = js.native): Unit
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on.
The EventTarget.addEventListener() method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events (such as XMLHttpRequest).
MDN
- Definition Classes
- EventTarget
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- def create(): XMLHttpRequest
-
def
dispatchEvent(evt: Event): Boolean
Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order.
Dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) apply to events dispatched manually with dispatchEvent().
MDN
- Definition Classes
- EventTarget
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def getAllResponseHeaders(): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def getResponseHeader(header: String): String
-
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- var onabort: Function1[Any, _]
- var onerror: Function1[ErrorEvent, _]
- var onload: Function1[Event, _]
- var onloadend: Function1[ProgressEvent, _]
- var onloadstart: Function1[Any, _]
- var onprogress: Function1[ProgressEvent, _]
- var onreadystatechange: Function1[Event, _]
- var ontimeout: Function1[Event, _]
-
def
open(method: String, url: String, async: Boolean = js.native, user: String = js.native, password: String = js.native): Unit
Initializes a request.
Initializes a request. This method is to be used from JavaScript code; to initialize a request from native code, use openRequest()instead.
MDN
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
readyState: Int
The state of the request: Value State Description 0 UNSENT open()has not been called yet.
The state of the request: Value State Description 0 UNSENT open()has not been called yet. 1 OPENED send()has not been called yet. 2 HEADERS_RECEIVED send() has been called, and headers and status are available. 3 LOADING Downloading; responseText holds partial data. 4 DONE The operation is complete.
MDN
-
def
removeEventListener[T <: Event](type: String, listener: Function1[T, _], options: EventListenerOptions): Unit
Removes the event listener previously registered with EventTarget.addEventListener.
Removes the event listener previously registered with EventTarget.addEventListener.
This implementation accepts a settings object of type EventListenerOptions.
MDN
- Definition Classes
- EventTarget
-
def
removeEventListener[T <: Event](type: String, listener: Function1[T, _], useCapture: Boolean = js.native): Unit
Removes the event listener previously registered with EventTarget.addEventListener.
Removes the event listener previously registered with EventTarget.addEventListener.
MDN
- Definition Classes
- EventTarget
-
def
response: Any
The response entity body according to responseType, as an ArrayBuffer, Blob, Document, JavaScript object (for "json"), or string.
The response entity body according to responseType, as an ArrayBuffer, Blob, Document, JavaScript object (for "json"), or string. This is null if the request is not complete or was not successful.
MDN
-
def
responseText: String
The response to the request as text, or null if the request was unsuccessful or has not yet been sent.
The response to the request as text, or null if the request was unsuccessful or has not yet been sent.
MDN
-
var
responseType: String
Can be set to change the response type.
Can be set to change the response type. Value Data type of response property "" (empty string) String (this is the default) "arraybuffer" ArrayBuffer "blob" Blob "document" Document "json" JavaScript object, parsed from a JSON string returned by the server "text" String "moz-blob" Used by Firefox to allow retrieving partial Blob data from progress events. This lets your progress event handler start processing data while it's still being received. "moz-chunked-text" Similar to "text", but is streaming. This means that the value in response is only available during dispatch of the "progress" event and only contains the data received since the last "progress" event. When response is accessed during a "progress" event it contains a string with the data. Otherwise it returns null. This mode currently only works in Firefox. "moz-chunked-arraybuffer" Similar to "arraybuffer", but is streaming. This means that the value in response is only available during dispatch of the "progress" event and only contains the data received since the last "progress" event. When response is accessed during a "progress" event it contains a string with the data. Otherwise it returns null. This mode currently only works in Firefox. Note: Starting with Gecko 11.0 (Firefox 11.0 / Thunderbird 11.0 / SeaMonkey 2.8), as well as WebKit build 528, these browsers no longer let you use the responseType attribute when performing synchronous requests. Attempting to do so throws an NS_ERROR_DOM_INVALID_ACCESS_ERR exception. This change has been proposed to the W3C for standardization.
MDN
-
def
responseURL: UndefOr[String]
Returns the serialized URL of the response or the empty string if the URL is null.
Returns the serialized URL of the response or the empty string if the URL is null. If the URL is returned, URL fragment if present in the URL will be stripped away. The value of responseURL will be the final URL obtained after any redirects.
This property should be a String, but it isn't implemented by IE, even as new as IE11, hence it must be UndefOr.
MDN
-
def
responseXML: Document
The response to the request as a DOM Document object, or null if the request was unsuccessful, has not yet been sent, or cannot be parsed as XML or HTML.
The response to the request as a DOM Document object, or null if the request was unsuccessful, has not yet been sent, or cannot be parsed as XML or HTML. The response is parsed as if it were a text/xml stream. When the responseType is set to "document" and the request has been made asynchronously, the response is parsed as a text/html stream. Note: If the server doesn't apply the text/xml Content-Type header, you can use overrideMimeType()to force XMLHttpRequest to parse it as XML anyway.
MDN
-
def
send(data: Any = js.native): Unit
Sends the request.
Sends the request. If the request is asynchronous (which is the default), this method returns as soon as the request is sent. If the request is synchronous, this method doesn't return until the response has arrived.
MDN
-
def
setRequestHeader(header: String, value: String): Unit
Sets the value of an HTTP request header.
Sets the value of an HTTP request header. You must call setRequestHeader() after open(), but before send(). If this method is called several times with the same header, the values are merged into one single request header.
MDN
-
def
status: Int
The status of the response to the request.
The status of the response to the request. This is the HTTP result code (for example, status is 200 for a successful request).
MDN
-
def
statusText: String
The response string returned by the HTTP server.
The response string returned by the HTTP server. Unlike status, this includes the entire text of the response message ("200 OK", for example).
MDN
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
var
timeout: Double
The number of milliseconds a request can take before automatically being terminated.
The number of milliseconds a request can take before automatically being terminated. A value of 0 (which is the default) means there is no timeout. Note: You may not use a timeout for synchronous requests with an owning window.
MDN
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
var
upload: XMLHttpRequestEventTarget
The upload process can be tracked by adding an event listener to upload.
The upload process can be tracked by adding an event listener to upload.
MDN
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
var
withCredentials: Boolean
Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.
Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers. The default is false. Note: This never affects same-site requests. Note: Starting with Gecko 11.0 (Firefox 11.0 / Thunderbird 11.0 / SeaMonkey 2.8), Gecko no longer lets you use the withCredentials attribute when performing synchronous requests. Attempting to do so throws an NS_ERROR_DOM_INVALID_ACCESS_ERR exception.
MDN