62,072
社区成员
发帖
与我相关
我的任务
分享
<script type ="text/javascript">
onload = function() {
var xhr = new XMLHttpRequest();
var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?";
xhr.open("get", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
var jsonData = eval("(" + xhr.responseText + ")"); //得到JSON对象
alert(jsonData.stories.length); //得到json数据数量
//......
}
}
}
xhr.send();
}
</script>
<script type="text/javascript">
$().ready(function() {
var url = "http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=?";
$.getJSON(url, function(data) {
alert(data.stories.length);
});
});
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>融化这个BUG。</title>
<script type="text/javascript">
var list = null;
function callbackFun(o) {
list = o;
}
</script>
<script src="http://services.digg.com/stories/top?appkey=http%3A%2F%2Fmashup.com&type=javascript&callback=callbackFun" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
document.write(list.count);
</script>
</body>
</html>