I'm using XMLHttpRequest to get content from a page. I have code that works to create the object and submit showing alert
. I wanted to get the contents of a page in assync
mode.
This is the code creating the object:
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else { /
alert("Nao suporta XMLHTTPRequest...");
return;
}
//methodo de transmicao
//url
// true mode asynchrone
xhr_object.open("GET", "http://page.htm", true);
//4 (complete)
xhr_object.onreadystatechange = function() {
if(xhr_object.readyState == 4) alert("Request!");
}
//executar request
xhr_object.send(null);