I have this functions
function C(Id)
{
var A=Y(Id);
alert("A"+A);
}
function Y(idImagen)
{
var HR= new XMLHttpRequest();
HR.open("Post",DownloadImg_Php,true);
HR.setRequestHeader("Content-type","application/x-www-form-urlencoded");
HR.onreadystatechange=function()
{
if(HR.readyState==4 && HR.status==200)
{
return HR.responseText;
}
}
//Ejecuta el Objeto
HR.send(Variables);
}
So here is my problem, the alert prints undifined and im pretty sure it is because the line runs befor XMLObject finish de request which is supose tu return and asign the expected value to the variable A.
So my question is, how can stop the code from running until value from Y is returned.