开发者

Twitter client with JQuery not working in Firefox

开发者 https://www.devze.com 2023-01-03 03:48 出处:网络
I\'ve got a little script that fetches my latest tweets. I use JQuery\'s $.getJSON() method to fetch my tweets.

I've got a little script that fetches my latest tweets. I use JQuery's $.getJSON() method to fetch my tweets.

The script works well with Chrome and Safari but when it comes to Firefox, nothing appears!

Here's the code:

var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=lpdahito&count=3&callback=?';
$.getJSON(url, function(data) {
    $('#tweets').html('<p>' + 
        data[0].text + '</p><p>' + 
        data[1].text + '</p><p>开发者_JS百科;' + 
        data[2].text + '</p>');
});


It works well using Firefox 3.6 mac. You can always add :

$.ajaxSetup({
    error:function(XMLHttpRequest, textStatus, errorThrown) {
        console.log(errorThrown);
    }
});

before your JSONP call to try to figure out what's wrong. But nothing's wrong here.


I had forgotten to tell Firefox when to call the script.

I added:

$(document).ready(function(){
  //my code here
});

Everything is fine now.

0

精彩评论

暂无评论...
验证码 换一张
取 消