I need to return the data from an nested ajax call but also need the ajax call to stay asynchronous.
I found some related questions but can't get it to work in the situation below. I assume returnData is being returned before the ajax call is done, but I can't find an solution.
function makeRequest(command, postData){
var returnData;
$.ajax({
url: 'call.php?command='+command,
data: postData,
type: 'POST'
}).done(function(data){
returnData = data;
});
return returnData;
}