I’m using ajax to on one of my pages and using the function below to get a pages response. I want to be able to have the function get_page_response return the value of the page response. However, I cant figure out a way to do it since the returning xmlHttp.responseText in the onreadystatechange method. I was hoping to be able to do something like get_page_response.return(xmlHttp.responseText), but that doesn’t work, any ideas?
[CODE]
function get_page_response(url){
var xmlHttp;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e){
try{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch (e){
//browser does not support AJAX
return false;
}
}
}
xmlHttp.onreadystatechange = function(){
return xmlHttp.responseText;
}
xmlHttp.open(“GET”,url, true);
xmlHttp.send(null);
}