942,526 Members | Top Members by Rank

Ad:
Jul 22nd, 2010
0

jQuery twitter feed

Expand Post »
Ok so I am trying to setup on my site to have 6 of my recent tweets. I am trying to use the .getJSON method and it is just not working.


JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $.getJSON("http://api.twitter.com/1/statuses/user_timeline/jrock2004.json", function(data) {
  2. $.each(data, function(){
  3. $('<div></div>')
  4. .hide()
  5. .append('<span>' + this.text + '</span>')
  6. .appendTo('#tweets')
  7. .fadeIn();
  8. });
  9. });

Any ideas? I thought maybe it might be easier to try xml as well but I have not tried that. Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 2
Light Poster
jrock2004 is offline Offline
34 posts
since Jul 2010
Jul 23rd, 2010
0
Re: jQuery twitter feed
Try running the above and check out the json request in firebug's net tab. Is the request going out? Does it get errors? Firebug will show you what the headers look like, what your status code is and what is being returned (as well as params sent if applicable). Your status should return as a 200 (pieces on the page such as static images and javascript will usually return 304 after the page has loaded at least once). Here is a link to twitter api documentation on status codes and what they mean to twitter apps: http://dev.twitter.com/pages/responses_errors
Reputation Points: 27
Solved Threads: 45
Posting Whiz in Training
scrappedcola is offline Offline
219 posts
since Dec 2009
Jul 24th, 2010
0
Re: jQuery twitter feed
You need to add a callback to the URL to make it a JSONP request because you cannot do cross domain JSON requests.

So to fix your code, it's as easy as adding '?callback=?' to the end of your URL.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. $.getJSON("http://api.twitter.com/1/statuses/user_timeline/jrock2004.json?callback=?", function(data) {
  2. $.each(data, function(){
  3. $('<div></div>')
  4. .hide()
  5. .append('<span>' + this.text + '</span>')
  6. .appendTo('#tweets')
  7. .fadeIn();
  8. });
  9. });
Last edited by JJenZz; Jul 24th, 2010 at 7:12 am.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
JJenZz is offline Offline
6 posts
since Jul 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: XML Parser error
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Problem with AJAX





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC