Ad:
 
Similar Threads
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
Reputation Points: 10
Solved Threads: 2
Light Poster
jrock2004 is offline Offline
26 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: 19
Solved Threads: 22
Junior Poster
scrappedcola is offline Offline
125 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 6:12 am.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
JJenZz is offline Offline
6 posts
since Jul 2010
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: cannot pass string to javascript function from Ajax
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Problem with AJAX





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


Follow us on Twitter


© 2010 DaniWeb® LLC