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>
精彩评论