XMLHttpRequest class
Allows to interact with the serversAttributes
| readyState | the code successively changes value from 0 to 4 that means for "ready". |
| status | 200 is OK |
| 404 | if the page is not found. |
| responseText | holds loaded data as a string of characters. |
| responseXml | holds an XML loaded file, DOM's method allows to extract data. |
| onreadystatechange | property that takes a function as value that is invoked when the readystatechange event is dispatched. |
Methods
| open(mode, url, boolean) | mode: type of request, GET or POST url: the location of the file, with a path. boolean: true (asynchronous) / false (synchronous). optionally, a login and a password may be added to arguments. |
| send("string") | null for a GET command. |

taken from java.sun.com
Firstly, we need to know how to create an XMLHTTPRequest object. The process differs slightly depending on whether you are using Internet Explorer (5+) with ActiveX enabled, or a standards-compliant browser such as Mozilla Firefox.
With IE, the request looks like:
http = new ActiveXObject("Microsoft.XMLHTTP");
whereas in a standards-compliant browser we can instantiate the object directly:
http = new XMLHttpRequest();Now we need to write some event handler which will be part of web page (user's page)
We can make our request of the server by using a GET method to an appropriate server-side script. Here's an example event handler called updateData which assumes that we have created our XMLHTTPRequest object (as above) and called it http:
function updateData(param) {
var myurl = [here I insert the URL to my server script];
http.open("GET", myurl + "?id=" + escape(param), true);
http.onreadystatechange = useHttpResponse;
http.send(null);
}
Thirdly, then, we need to write a function useHttpResponse which will establish when the server has completed our request, and do something useful with the data it has returned:
function useHttpResponse() {
if (http.readyState == 4) {
var textout = http.responseText;
document.write.textout;
}
}
In this case, we have received our information as simple text via the responseText property of our XMLHTTPRequest object.