Thursday, November 1, 2007

W3C accepted XMLHttpRequest

Finally W3C accepted the XMLHttpRequest as an standard object.
You can review the draft of specification here.

And from now on all the browsers will have a united way to create an object of this class:

var client = new win.XMLHttpRequest()

And more cross-browser compatibility!

The interface that all browsers have to implement for this object (class) is like this:

interface XMLHttpRequest {
// event handler
attribute EventListener onreadystatechange;

// state
const unsigned short UNSENT = 0;
const unsigned short OPENED = 1;
const unsigned short HEADERS_RECEIVED = 2;
const unsigned short LOADING = 3;
const unsigned short DONE = 4;
readonly attribute unsigned short readyState;

// request
void open(in DOMString method, in DOMString url);
void open(in DOMString method, in DOMString url, in boolean async);
void open(in DOMString method, in DOMString url, in boolean async, in DOMString user);
void open(in DOMString method, in DOMString url, in boolean async, in DOMString user, in DOMString password);
void setRequestHeader(in DOMString header, in DOMString value);
void send();
void send(in DOMString data);
void send(in Document data);
void abort();

// response
DOMString getAllResponseHeaders();
DOMString getResponseHeader(in DOMString header);
readonly attribute DOMString responseText;
readonly attribute Document responseXML;
readonly attribute unsigned short status;
readonly attribute DOMString statusText;
};

It's also natively implemented in IE7 which means no more ActiveX. ;)

No comments: