Check the article How to get the response of XMLHttpRequest
In a nutshell, XMLHttpRequest is asynchronous by default, so you need to register a callback function on the onreadystate.
var request = new XMLHttpRequest();
request.onreadystatechange=function(){
if (request.readyState==4 && request.status==200){
alert(request.status);
// To get the response use request.responseText;
}
}
request.open("GET", "http://www.google.com");
request.send(null);
Note that for older versions of IE (IE5 and IE6), you need to get the request from an ActiveX Object as follows:
variable=new ActiveXObject("Microsoft.XMLHTTP");