Json twitter getting the coordinates and message
I want to get the tweets from this result, but i cannot get a correct input. I want to have the coordinates.
$.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);
}
}
I get this as result:
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...}
but when i ask tweet i get undefined
This is because you're trying to run a for loop inside of an each statement. your tweets
object is not an array. You should just change tweets
to tweet
since you're pulling them down individually from your $.each()
method.
精彩评论