I'm trying to make a function that sends an XMLHttpRequest and return a string with the contents of the response, but it always returns null. How do I fix this?
Code:
function getPage() {
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.open('GET','page.php',false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
if ($.browser.msie) return xmlDoc.xml;
else return (new XMLSerializer()).serializeToString(xmlDoc);
}
xmlhttp.responseTextinstead ofxmlhttp.responseXML. Is$.get()asynchronous?