开发者

Loading json from different domain?

Is there any way to load the json provided by the http://search.twitter.com/search.json URL on to my page via ajax? Everything I've tried gives me:

XMLHttpRequest cannot load http://search.twitter.co开发者_如何学Cm/search.json. Origin null is not allowed by Access-Control-Allow-Origin.

If not, then whats the point of having such services in the first place?W


Use JSONP, or JSON with padding:

<script type = "text/javascript">
    window.getTwitterResults = function(data) {
      console.log(JSON.stringify(data));
    };
</script>
<script type = "text/javascript" src = "http://search.twitter.com/search.json?q=cheese&callback=getTwitterResults"></script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜