public
Last active

Example of jquery.when

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$.when( getTweets('austintexasgov'),
getTweets('greenling_com'),
getTweets('themomandpops')
).done(function(atxArgs, greenlingArgs, momandpopsArgs){
var allTweets = [].concat(atxArgs[0]).concat(greenlingArgs[0]).concat(momandpopsArgs[0]);
var sortedTweets = sortTweets(allTweets);
showTweets(sortedTweets);
});
 
var getTweets = function(user){
var url='http://twitter.com/status/user_timeline/' + user + '.json';
return $.get(url, {count:5}, null, 'jsonp');
}
 
// see it in action at http://jsfiddle.net/94PGy/4/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.