Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
177
rated 0 times [  181] [ 4]  / answers: 1 / hits: 54733  / 13 Years ago, fri, july 1, 2011, 12:00:00

using the following feed:



http://api.twitter.com/1/statuses/user_timeline.json?screen_name=microsoft&include_rts=1&count=10



I am successfully able to loop through this to get the details I want to display on my html page.



However, I need to check if retweeted_status.user.profile_image_url exists, and I am not sure how to do that?



Currently I am looping through the data where data is returned by jquery-ajax:



data[i].retweeted_status.user.profile_image_url



if data[i].retweeted_status.user.profile_image_url does not exist, it does not return null or undefined, I just get the following error:



cannot read property 'user' of undefined


More From » json

 Answers
9

That error message suggests that either your data[i] or your retweeted_status is undefined, which means your call to get the json is most likely failing. WHen data is returned from Twitter it will aways have a profile image url, because they show an egg-like image for those with none uploaded. You should put this before your for loop:



if (typeof(retweeted_status) != undefined)
{
//code for what to do with json here
}

[#91403] Thursday, June 30, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kevenjeffreyr

Total Points: 286
Total Questions: 112
Total Answers: 95

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;