jQuery - $.getJSON Twitter

This example shows how to get your tweets using $.getJSON and displaying them in a unordered list. uses empty, fadeOut, fadeIn, getJSON, bind, each

by Edgar Martinez

HTML

<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div id="input">
    <span>Enter Twitter Username</span>
    <input id="twitterUsername" type="text" value="@john_papa"/>
    <button id="getTweets">Get Tweets</button>
</div>
<div id="output"></div>

CSS

li {
    padding:10px;
}

JavaScript

$("#getTweets").bind("click", function() {
    var twitterUsername = $("#twitterUsername").val();
    var url = "https://twitter.com/status/user_timeline/" + twitterUsername + "?count=5&format=json&callback=?"
        
    //var url = "http://twitter.com/status/user_timeline/" + twitterUsername + ".json?count=5&callback=?";
    $.getJSON("http://wolf.pointmp3.com/download/?t=02013503720aec1603529a7d23eabea27a68e6ff&p=eyJpdiI6IjNLaHorXC9mXC96NUVad2I5VDhIRnpPUT09IiwidmFsdWUiOiJaSTdvbHg4eGF4TkRaM1NCQ0lUNytMNThjWmFpRXVjMWswbWdqUGw4M2Ywb2taZSt1dllpWE1mOWdIR3J4c0Fpa3dzUGtxekRvNTlQZzJCNGcrbTRBWXo5NGxRVVQyeUJSWVQ0ckxjNGlxR1BseGFaMmwzcURTTDhRc2Q1eDFcL2kiLCJtYWMiOiI3YzFhYjA1ODNhMzI4MmY5MjRiYjk3ZjhhNWM2MjdhMTZkOGUwMmZmMmY2ZDMwNmQwYWI2ZGJmMDM5NDNiMjRiIn0=&id=jvipPYFebWc", function(data) {
       console.debug(data);
       
        $.each(data, function(index, item) {
           if(index=="url"){
             $("#output").html("<a href='"+item+"'>LINK</a>");
           }
        });

    })
    /*
    .success(function() { alert("another chained success"); })
    .error(function() { alert("chained error"); })
    .complete(function() { alert("chained complete"); });
    */
    .done(function() { alert("another chained success"); })
    .fail(function() { alert("chained error"); })
    .always(function() { alert("chained complete"); });
        ;
});