Possible Duplicate:
Multiple ajax calls inside a each() function.. then do something once ALL of them are finished?
Basically, I want to run a function after an each() loop containing load() for each loop completely finishes. It takes some time to load each link and is waiting for the browser to catch up but the script has already moved on to the next step. Any ideas?
jQuery('#theId a').each(function() { // contains many links
toLoad = jQuery(this).attr('href');
jQuery('#containment').load(toLoad, function(response) {
//do stuff
});
});
//... Do stuff after the above is really complete.