我是一名完整的Tableau新手,正在學習本教程。我做了一個getJSON()請求,我的腳本掛起,從不返回。我究竟做錯了什麼?我測試了瀏覽器中的鏈接,並且幾乎立即返回響應,所以它不是速度問題。Tableau JSON請求不起作用
(function() {
var myConnector = tableau.makeConnector();
myConnector.getSchema = function (schemaCallback) {
var cols = [
{id: "mag", alias: "magnitude", dataType: tableau.dataTypeEnum.float},
{id: "title", alias: "title", dataType: tableau.dataTypeEnum.string},
{id: "url", alias: "url", dataType: tableau.dataTypeEnum.string},
{id: "lat", alias: "latitude", columnRole: "dimension", dataType: tableau.dataTypeEnum.float},
{id: "lon", alias: "longitude", columnRole: "dimension", dataType: tableau.dataTypeEnum.float}
];
var tableInfo = {
id: "earthquakeFeed",
alias: "Significant Earthquakes in the last seven days",
columns: cols
};
schemaCallback([tableInfo]);
//tableau.log("Hello WDC!");
};
myConnector.getData = function (table, doneCallback) {
$.getJSON("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_week.geojson", function (resp) {
var feat = resp.features,
tableData = [];
// Iterate over the JSON object
for (var i = 0, len = feat.length; i < len; i++) {
tableData.push({
"id": feat[i].id,
"mag": feat[i].properties.mag,
"title": feat[i].properties.title,
"lon": feat[i].geometry.coordinates[0],
"lat": feat[i].geometry.coordinates[1]
});
}
table.appendRows(tableData);
doneCallback();
});
};
tableau.registerConnector(myConnector);
$(document).ready(function() {
$("#submitButton").click(function() {
tableau.connectionName = "Stock Data for ";
tableau.connectionData = "tickerSymbol";
tableau.submit();
});
});})();