I'm trying to include list of my followers on my site. Here's my code:
$.getJSON('http://twitter.com/statuses/f开发者_如何学编程ollowers.json?screen_name=username',function(data){
alert(data);
});
However, nothing happens. No errors, other js still works, just this doesn't work. What is wrong?
Martti Laine
Ps. I'm using jQuery for this, as page loads faster, when not using php. Content is shown faster.
You need to trigger JSONP by adding this to the end of your URL: &callback=?
, like this:
$.getJSON('http://twitter.com/statuses/followers.json?screen_name=username&callback=?',function(data){
alert(data);
});
You can see it getting a response here. Without doing this it's attempting to make an XmlHttpRequest fetch of the data, which is blocked by the same-origin policy.
精彩评论