Skip to content

@chribben /async.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Async in jQuery with nested $.when
function A(){
promises1 = new Array();
promises2 = new Array();
for (var i = start; i < end; i++)
{
B(someUri);
}
await();
}
function await()
{
$.when.apply($, promises1).always(function() {
$.when.apply($, promises2).always(function() {
doSomethingToTheDataStoredInSomeGlobalVariableBelow();
});
});
}
function B(uri){
promises1.push($.getJSON(uri, function(data){
someCollectionFrom_data.each(function () {
promises2.push($.get(someUriFrom_this, function(data){
extractSomeStuffFrom_data_AndStoreInSomeGlobalVariable();
}));
}
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.