var $results = $('#results'),
loadInterval = 2000;
(function loader() {
// Note: this Twitter API url does not require authentication
// For more info on the twitter API, see
// http://apiwiki.twitter.com/w/page/22554679/Twitter-API-Documentation
$.ajax('http://api.twitter.com/1/statuses/public_timeline.json', {
type: "GET",
dataType: "jsonp",
success: function( data ) {
var tweet;
$results.hide(200, function() {
$results.empty();
for ( var i = 0; i < 5; i++ ) {
tweet = data[i];
$results.append('<div class="result">'
+ '<h2>' + tweet.user.name + '</h2>'
+ '<img src="' + tweet.user.profile_image_url + '">'
+ '<p>' + tweet.text + '</p>'
+ '</div>');
}
$results.show(200, function() {
setTimeout(loader, loadInterval);
});
});
}
});
})();