whatf
whatf

Reputation: 6458

parsing json by jquery's getJSON for twitter api search results not working

Problem : for a given query i try to parse the json from the twitter api results.

Codes at : http://jsfiddle.net/Nstnx/176/

Upvotes: 0

Views: 3058

Answers (3)

Rafay
Rafay

Reputation: 31033

try this

var url = "http://search.twitter.com/search.json?callback=?&rpp=50&q='ramlila'";
    $.getJSON(url, function(data) {
  var items = [];      

        var twitterList = $( "<ul />" );
        $.each( data.results, function( index, item ) {
           alert(data.results[index].text);
            $( "<li />", { "text" : item.from_user} )
                .appendTo( twitterList );
        });
        $( "#output" ).fadeOut( "fast", function(){
            $( this ).empty()
                .append( twitterList )
                .fadeIn( "slow" );            
        });


});

http://jsfiddle.net/Nstnx/182/

Upvotes: 0

ipr101
ipr101

Reputation: 24236

I'm waaaay behind on this, and cwallenpoole should get any credit due for being much quicker , but here's a working demo -

http://jsfiddle.net/nkQ4Q/

Upvotes: 1

cwallenpoole
cwallenpoole

Reputation: 81988

The data parameter has a results property. You want to iterate over that instead of over the data directly:

This

$.each( data, function( index, item ) {

Should be

$.each( data.results, function( index, item ) {

Upvotes: 5

Related Questions