Last active
September 27, 2015 17:07
-
-
Save joshuaflanagan/1302978 to your computer and use it in GitHub Desktop.
Example of jquery.when
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment