javascript - How can i return something what callback function fetches -
i have ajax library can see code here. have function uses ajax function , needs return ajax function returns this
function returnmydata(){ var data; ajax.get("somedomain",function(err,dt){ if(dt){data= dt} }); return data; }
here looks fine javascript return null because callback wont fetch data yet due multi thread nature of javascript. question how can wait till data fetched , return tried use while freezes browser or gives unresponsive script error.
Comments
Post a Comment