In the code below I have to have the alert statement marked by the two *s. Else firefox returns an empty 'temp' even though the 'webtext' is read correctly. How can I remove this requirement?
Code:
function getdatalinks(diagnosis,min_age,max_age,gender)
{
var temp="";
var urii="given URL";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",urii,true);
xmlhttp.send(null);
xmlhttp.onreadystatechange=function()
{//the request is in ready state but not complete
if(xmlhttp.readyState==4 && xmlhttp.status==200)
{//request is complete
webtext=String(xmlhttp.responseText);
alert(webtext);
temp=webtext;
}
};
alert(temp); //**
return(temp);
}
Comment