extern class js.html.XMLHttpRequestextends EventTargetAvailable in js

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 at a URL. 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).

To create an instance of XMLHttpRequest, simply do this:

var req = new XMLHttpRequest();

For details about how to use XMLHttpRequest, see Using XMLHttpRequest.

Documentation for this class was provided by MDN.
var onabort : EventListener var onerror : EventListener var onload : EventListener var onloadend : EventListener var onloadstart : EventListener var onprogress : EventListener var onreadystatechange : EventListener var readyState(default,null) : Int

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.
var response(default,null) : DynamicThe response entity body according to responseType, as an ArrayBuffer, Blob, Document , JavaScript object (for "moz-json"), or string. This is NULL if the request is not complete or was not successful. Getter throws DOMException. var responseText(default,null) : StringThe response to the request as text, or null if the request was unsuccessful or has not yet been sent. Read-only. Getter throws DOMException. var responseType : String

Can be set to change the response type. This tells the server what format you want the response to be in.

Value Data type of response property
empty string String (this is the default)
"arraybuffer" ArrayBuffer
"blob" Blob
"document" Document
"text" String
"moz-json" JavaScript object, parsed from a JSON string returned by the server Requires Gecko 9.0
Setter throws DOMException.
var responseXML(default,null) : 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. The response is parsed as if it were a text/xml stream. Read-only.

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.
Getter throws DOMException.
var status(default,null) : IntThe status of the response to the request. This is the HTTP result code (for example, status is 200 for a successful request). Read-only. Getter throws DOMException. var statusText(default,null) : StringThe response string returned by the HTTP server. Unlike status, this includes the entire text of the response message ("200 OK", for example). Read-only. Getter throws DOMException. var upload(default,null) : XMLHttpRequestUploadThe upload process can be tracked by adding an event listener to upload. New in Firefox 3.5 var withCredentials : Bool

Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers. New in Firefox 3.5

Note: This never affects same-site requests.

The default is false.

Setter throws DOMException.
function new() : Void function abort() : Void function getAllResponseHeaders() : String function getResponseHeader( header : String ) : String function open( method : String, url : String, ?async : Bool, ?user : String, ?password : String ) : Void function overrideMimeType( override_ : String ) : Void function send( data : DOMFormData ) : Void

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.

Note: Any event listeners you wish to set must be set before calling send().
This may be an nsIDocument, nsIInputStream, or a string (an nsISupportsString if called from native code) that is used to populate the body of a POST request. Starting with Gecko 1.9.2, you may also specify an DOMFile , and starting with Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) you may also specify a FormData object.
Throws DOMException.
function setRequestHeader( header : String, value : String ) : Void static inline var DONE : IntThe operation is complete. static inline var HEADERS_RECEIVED : Intsend() has been called, and headers and status are available. static inline var LOADING : IntDownloading; responseText holds partial data. static inline var OPENED : Intsend()has not been called yet. static inline var UNSENT : Intopen()has not been called yet.
version #18376, modified 2013-05-01 11:59:02 by api
0 comment