0
YQL我想一些幫助,解決這個代碼,它試圖返回JSON應包含這樣的:獲取JSON從使用jQuery不工作
{
"col0": "4-Jan-17",
"col1": "115.85",
"col2": "116.51",
"col3": "115.75",
"col4": "116.02",
"col5": "21118116"
},
{
"col0": "3-Jan-17",
"col1": "115.80",
"col2": "116.33",
"col3": "114.76",
"col4": "116.15",
"col5": "28781865"
}
這裏是我的代碼,因爲它是現在:
function getData() {
var dataFormat= "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
var site = 'http://www.google.com/finance/historical?q='+ 'AAPL' +'&startdate=Jan+01%2C+2017&enddate=Jan+05%2C+2017&output=csv';
var symbol = $("#txtSymbol").val();
var historicalQ = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from csv where url="' + site + '"') + dataFormat;
$(function() {
$.getJSON(historicalQ, function(json) {
var test = json;
console.log(test);
});
});
}
我本來使用雅虎的數據庫,但他們最近關閉下來所以在此我想將其翻譯爲使用谷歌的API。當我運行它,我得到的東西看起來完全錯誤:
[object Object] {
query: [object Object] {
count: 4,
created: "2017-05-24T20:26:37Z",
lang: "en-US",
results: [object Object] { ... }
}
}
我知道,谷歌鏈接的作品,因爲我已經在YQL控制檯測試它,所以我認爲錯誤是在我的代碼。任何幫助,將不勝感激!