Rest and JSON in JQuery - Twitter Gadget

I am sure you guys must have seem lot of gadget floating around the web for twitter, yahoo, google and what not.

Did you ever thought that writing a small gadget is such a small and minutes job with jquery and the apis exposed by these social networking sites like facebook and twitter. I just tried hands on one of the those and it was quick to get this twitter gadget ready to be shared.

Simple JSON script like the one below can do the whole trick for you.


$(document).ready(function(){
var tweeturl = "http://twitter.com/status/user_timeline/
rahuljuneja.json?count=5&callback=?";
$.getJSON(tweeturl, function(data){
$.each(data, function(i, item) {
$('

').addClass(i%2 ? 'even' : 'odd')
.html(item.text)
.prependTo('#tweet');
});
});
});

0 comments:

Post a Comment