Sunday, March 29, 2009

Ajax: XMLHttpRequest(XHR)

https://developer.mozilla.org/en/XMLHttpRequest
https://developer.mozilla.org/En/HTTP_Access_Control

To use XHR, call sequence is as follows:

//1. init
var xmlHttp = new XMLHttpRequest();
//2. setup request
xmlHttp.open("GET", url, true);
//3. set callback function
xmlHttp.onreadystatechange=callback;
//4. let's go
xmlHttp.send(null);


Current implementation of XHR usually follow same-origin policy. That means you can only retrieve data on same domain... You can prepare the content using PHP...

No comments:

Related Posts Plugin for WordPress, Blogger...