我正在尝试在 reddit 上获取某个页面的 JSON 文件,但它无缘无故地取消了..
这是我试图用 JSON 解析的 URL。http://reddit.com/r/VillagePorn/.json
更新代码:
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Sin título 1</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "GET",
dataType: "json",
url: "http://reddit.com/r/VillagePorn/.json?jsonp=?",
success: function (data) {
$.each(data.data.children, function(i,item){
$("<img/>").attr("src", item.data.url).appendTo("#res");
});
}
});
});
</script>
</head>
<body>
<div id="res"></div>
</body>
</html>