1
我試圖解析Coinbase API來拉回比特幣的當前價格。這裏是我的代碼:解析JSON - 應該很簡單。我錯過了什麼?
var mtgoxAPI = "https://coinbase.com/api/v1/prices/spot_rate";
$.getJSON(mtgoxAPI, function (json) {
// Set the variables from the results array
var price = json.amount;
// Set the table td text
$('#btc-price').text(price);
});
任何幫助,將不勝感激。
「解析」在哪裏?它是由jQuery自動完成的,所以我真正問的是*問題是什麼* (因爲它不是「解析」) - 錯誤可能在於訪問失敗,例如「XMLHttpRequest無法加載...否」訪問控制 - 允許來源「標題出現在請求的資源上」或其他網絡/意外響應問題。 – user2864740