I have an ajax library You can see the code here. I have another function what uses ajax function and needs to return what ajax function returns simply something like this
function returnMyData(){
var data;
ajax.get("someDomain",function(err,dt){
if(dt){data= dt}
});
return data;
}
Here everything looks fine but javascript will return null because callback wont fetch the data yet due to multi thread nature of javascript. So my question how can i wait till data is fetched and return then i tried to use while but it freezes the browser or gives unresponsive script error.