【发布时间】:2016-09-27 11:39:12
【问题描述】:
我正在尝试获取一些 JSON 数据。我可以在普通的网络浏览器中很好地访问数据,就像这样:http://www.ebrent.net/apis/tsp.php?fund=G+Fund&start=2003-01-01&end=2004-01-01,但我无法让它在 jQuery 中工作。我做错了什么?
请看我的jsFiddle:https://jsfiddle.net/MrSnrub/mq31hwuj/
var tsp_api = '//www.ebrent.net/apis/tsp.php?start=2003-01-01&end=2004-01-01';
$.getJSON( tsp_api, function(json) {
// This alert never gets called.
alert("Success!");
// Set the variables from the results array
var data = json;
// console.log('Data : ', data);
// Set the div's text
$('#div-data').text(data);
});
【问题讨论】:
-
是否启用了 www.ebrent.net CORS?