Is it possible to safely wait for async request to finish and then return value from function. Will something like this cause any problems.
Using jQuery
function test()
{
var $request = ...; //Async promise
var done = false;
while(!done)
{
$request.always(function(){
done = true ;
}) ;
}
return true ;
}
[Update] As @Ninsly pointed out, javascript only has one thread so using a loop is not an option.
Duplicate JavaScript asynchronous return value / assignment with jQuery