0

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.

$.getJSON("http://api.twitter.com/1/statuses/user_timeline/jrock2004.json", function(data) {
        $.each(data, function(){
            $('<div></div>')
                .hide()
                .append('<span>' + this.text + '</span>')
                .appendTo('#tweets')
                .fadeIn();                             
        });
    });

Any ideas? I thought maybe it might be easier to try xml as well but I have not tried that. Thanks

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by JJenZz
0

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

0

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.

$.getJSON("http://api.twitter.com/1/statuses/user_timeline/jrock2004.json?callback=?", function(data) {
    $.each(data, function(){
        $('<div></div>')
            .hide()
            .append('<span>' + this.text + '</span>')
            .appendTo('#tweets')
            .fadeIn();
    });
});

Edited by JJenZz: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.