我試圖簡單地搜索Discogs數據庫並在HTML中顯示結果,但是當我嘗試執行jQuery函數getJSON時,它的行爲就好像我提供的URL不正確,因爲任何東西都不起作用在getJSON函數中。當我查看該函數在瀏覽器中創建的URL時,它會轉到正確的JSON搜索頁面並提供正確的結果,但不會讓我解析結果。Discogs API getJSON不起作用
有人可以告訴我是否存在Discogs API URL的問題我正在嘗試使用,還是因爲我的編碼語法在某處出錯?
在此先感謝。
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Discogs Search</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
$.getJSON("http://api.discogs.com/database/search?type=master&q=illmatic&page=1&per_page=100", function(data) {
$("#output").append("TEST");
var theid = data.results[0].id;
});
});
});
</script>
</head>
<body>
<button id="button">Search</button>
<div id="output"></div>
</body>
</html>