I'm having a problem making ajax fast and functional. 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'm sending an ajax and need the returned data for further processing.
If I set async to true, the function immediately returns empty 'arr' array, thus the whole script fails. But if I set async to false, then it works, but takes very long.
I have seen 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 any way I can asynchronously send all the ajax requests at the same time and let function wait and return arr[] after all ajax are done? If not, will the ajaxQueue work in my case? (rough example please?)