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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -