I am calling ajax to fetch a value from asp page and return to the calling javascript, and the code is like below
function getNameFromSession()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support AJAX");
return;
}
var url="getImageName.asp";
url=url+"?fetch_name=1";
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4)
{
alert(xmlhttp.responseText);
return xmlhttp.responseText;
}
}
}
alert in function shows correct value, but javascript get undefined as value, can anybody tell me how can I return the value from this ajax to javascript calling function