2011-08-19 91 views

回答

5

数据参数具有results属性。你要遍历该而不是通过直接的数据:

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

应该

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

试试这个

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/