0

There was an example of reading jsonp request in jquery given in stackoverflow. This below code works fine.

$(document).ready(function() {
   var url =  "http://api.twitter.com/1/statuses/user_timeline/codinghorror.json";
   $.getJSON(url + "?callback=?", null, function(tweets) {
    for(i in tweets) {
        tweet = tweets[i];
        $("#tweet-list").append(tweet.text + "<hr />");
    }
   });
});

I uploaded the json file into a temp webserver with url being http://cruzer.net76.net/twitter.json

But my json doesn't seemed to get parsed and the browser shows no errors/warnings.

Any help..

4

1 回答 1

1

您的代码按原样工作:http: //jsfiddle.net/vWRAw/

但是,从您的 temp-webserver 返回的 json 是 JSON 而不是 JSONP。如果您想以 JSON 格式请求它,请删除?callback=?这意味着您的临时网络服务器需要与发出请求的页面位于同一域中。

于 2012-07-25T19:13:53.750 回答