develop wherever and whenever you want...
Docs > XMLHttpRequest Class Summary

XMLHttpRequest Class Summary

XHR is used to support issuing HTTP requests and handling response text.

Example 
function ready() { 
var rs = this.readyState; 
if(rs == 2) 
document.writeln(this.getAllResponseHeaders()); 
else if(rs == 3) 
document.write('.'); 
else if(rs == 4) { 
document.writeln(this.status); 
document.writeln(this.statusText); 
document.writeln(this.responseText.length); 

}

xhr = new XMLHttpRequest(); 
xhr.onreadystatechange = ready; 
xhr.open("get", "http://www.apple.com"); 
xhr.send(); 
document.wait(); 

object XMLHttpRequest() 
Construct a new XHR object.

function onreadystatechange 
This property is set by the caller to a function that will receive status change notifications on the XHR object.

void open(method,url) 
Open a connection with a given HTTP method (e.g. "get" or "post") and URL.

void setRequestHeader(key,value) 
Set a request header key to a given value.

void send([string]) 
Issue the actual URL request and send string data (if method is "post"). Please note that you must have the application process events using document.wait() for the request to complete.

void abort() 
Cancel any pending XHR operations.

string getResponseHeader(key) 
Get the response header value for a given key.

string getAllResponseHeaders() 
Return a string containing all response header informatio. Each header key / value pair is separated by a new line and the key is separated from the value by a colon ':' character.

number readyState 
Used in the onreadystatechange callback to determine the current state of the XHR request: 1 = issued, 2 = headers received, 3 = in progress, 4 = completed.

string status 
Returned HTTP status code (e.g. 500).

string statusText 
String description of status returned.

string responseText 
Returned text from the host.