我想解析這個json http://openclipart.org/search/json/?&query=christmas&page=1&amount=4在我的html頁面。解析OpenClipArt api json到Html
我的代碼是
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.getJSON demo</title>
<style>
img {
height: 200px;
float: left;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<div id="images"></div>
<script>
(function() {
var api = "http://openclipart.org/search/json/?";
$.getJSON(api, {
query: "christmas",
page: "1",
amount: "4"
}).done(function(data) {
$.each(data.payload, function(i, item) {
$("<img>").attr("src", item.svg.png_thumb).appendTo("#images");
if (i === 3) {
return false;
}
});
});
})();
</script>
</body>
</html>
http://jsfiddle.net/2n8ax/,但什麼是錯的。
否 '訪問控制允許來源' 標頭出現在所請求的資源。 – CharliePrynn
他們已經修復了它:DDD謝謝openclipart <3 – user3041529