Skip to content

Instantly share code, notes, and snippets.

@NateHark
Created October 15, 2012 17:50
Show Gist options
  • Save NateHark/3893958 to your computer and use it in GitHub Desktop.
Save NateHark/3893958 to your computer and use it in GitHub Desktop.
async.forEach
$('a#start-foreach').click(function() {
var teams = ['seahawks', 'packers', 'steelers', 'chargers', 'chiefs' ];
async.forEach(
teams,
function(team, callback) {
setTimeout(function() {
$('div#foreach').append(team + '<br />');
callback();
}, Math.round(Math.random() * 5000));
},
function(err) {
$('div#foreach').append($('<p>').append('Done'));
}
);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment