2011-06-14 82 views
0

我想從此結果中獲取推文,但我無法獲得正確的輸入。我想要座標。Json twitter獲取座標和消息

$.ajax(
{ 
    dataType: 'jsonp', 
    url: 'http://search.twitter.com/search.json?&geocode=51.985103,5.89873,1mi', 
    success: function (data) 
    { 
console.log("hoi"); 
     $.each(data.results, function (i, tweets) 
     { 

      console.log(tweets); 

    for (var j = 0; j < tweets.length; j++) 
{ 
       var tweet = tweets[j]; 
      console.log(tweet); 
} 
} 

我得到這個結果爲:

Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...} 
    Object { from_user_id_str="23446954", location="ÜT: 51.983584,5.90971", more...} 
    Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...} 
    Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...} 
    Object { from_user_id_str="23446954", location="ÜT: 51.983584,5.90971", more...} 
    Object { from_user_id_str="237558800", location="ÜT: 51.9901586,5.9141892", more...} 

但是當我問鳴叫我得到了一個未定義

回答

1

這是因爲你想給每個語句在for循環中運行。您的tweets對象不是數組。您應該將tweets更改爲tweet,因爲您將其從$.each()方法單獨拉下來。