I have a problem with fast and functional ajax work. Here's the pseudo / prototype code:
function blah1(arg1){//arg1 is an array, roughly 10 elements var arr[]; $.each(arg1, function(i){ //blah code $.ajax({ //blah options async: true, success: function(data){ arr[i] = data.someInt; }//end success });//end ajax }//end each return arr; }//end function
Basically, I send ajax and need the returned data for further processing.
If I set async to true, the function immediately returns an empty arr array, so the whole script fails. But if I set async to false, then it works, but it takes a very long time.
I saw this $. ajaxQueue (); thing, but frankly, I donβt understand it at all, and I donβt know if it will work.
So, the question is, firstly, is there a way to send all ajax requests asynchronously at the same time and allow the wait and return arr [] functions after all ajax is complete? If not, will ajaxQueue work in my case? (an example?)
Jquonfused
source share