Tom*_*vic 144
这是工作示例:
<html><head><title>Twitter 2.0</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head><body>
<div id='tweet-list'></div>
<script type="text/javascript">
$(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 />");
}
});
});
</script>
</body></html>
Run Code Online (Sandbox Code Playgroud)
请注意所?callback=?
请求的URL的末尾.这表明getJSON
我们想要使用JSONP的功能.删除它,将使用vanilla JSON请求.由于相同的原始政策,这将失败.
您可以在JQuery站点上找到更多信息和示例:http://api.jquery.com/jQuery.getJSON/
归档时间: |
|
查看次数: |
79464 次 |
最近记录: |