0

I'm having a problem parsing valid Json from a Twitter List then displaying the list on the page.

Here is my code;

var url = "http://api.twitter.com/1/aplusk/lists/5676047/statuses.json&callback=?";

$.getJSON(url, function(data) { 
var results = '';

$(data.results).each(function() {
results += "<p class='tweet_result' id='tweet" + this.id_str + "'><a href='http://twitter.com/" + this.user.screen_name + "' title='' class='tweet_user'></p>";
});

$(results).prependTo("#twitter_results");
});

If you put the url in to www.jslint.com you can view the structure of the json

I'm new to json so I could be doing something stupid here.

Thanks in advance for your help and advice.

2
  • What is the problem you're having? Commented Feb 18, 2011 at 12:34
  • There are no jQuery errors but nothing is displaying when I append the results to a div. I'm sure I'm not correctly parsing the file or referring to the correct nodes. Commented Feb 18, 2011 at 12:43

1 Answer 1

1

The URL has to be:

http://api.twitter.com/1/aplusk/lists/5676047/statuses.json?callback=?

(Note the question mark instead of the ampersand)

Also see the returned object, it does'nt have a member "results", it's a native javascript-array.

You'll have to iterate over data itself:

$(data).each(function(i,item)

where you can access the properties inside via

item.someProperty
Sign up to request clarification or add additional context in comments.

1 Comment

Oh mannn... well i did say it was something studpid. Many thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.