JSON jQuery问题

eto*_*xin 0 javascript twitter jquery json

所以我第一次尝试JSON.我有这个我正在尝试输出的Twitter API提要.只是好奇我哪里出错了.附上是我的代码.

<!DOCTYPE html>

<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
  </head>
  <body>
    <ol class="result"></ol>
    <script>
      $.getJSON('http://api.twitter.com/1/trends/1105779.json', function(json) {
        alert(json.trends.query[1]);
        $('.result').html('<li>' + json.trends.query + '</li>');
      });
    </script>
  </body>
</html>
<!-- http://api.twitter.com/1/trends/1105779.json -->
Run Code Online (Sandbox Code Playgroud)

gle*_*ebm 5

将URL更改为'http://api.twitter.com/1/trends/1105779.json?callback=?'.

您的请求需要JSONP来解决XHR政策限制.

如果URL包含类似于callback=?jQuery的内容,则可以使请求成为JSONP请求.有关更多信息:http://api.jquery.com/jQuery.getJSON/