For simplicity, this page works only in FireFox / Mozilla. This is meant only as a demonstration of the basic XMLHTTPRequest object functionality. Further examples will use cross-platform libraries.
This example uses synchronous (modal) response-handling (the false flag in the request object creation indicates this.) Synchronous responses are easier to understand, but can cause the browser to hang.
function getAJAX(){
var request = new XMLHttpRequest();
request.open("GET", "test.html", false);
request.send(null);
if (request.status == 200){
//we got a response
alert(request.responseText);
} else {
//something went wrong
alert("Error- " + request.status + ": " + request.statusText);
} // end if
} // end function