Ich bin ein kompletter Tableau-Neuling, der an dem Tutorial arbeitet. Ich habe eine getJSON() Anfrage gemacht und mein Skript hängt und kehrt nie zurück. Was mache ich falsch? Ich habe den Link in meinem Browser getestet und eine Antwort wird fast sofort zurückgegeben, es ist also kein Geschwindigkeitsproblem.Tableau JSON-Anfrage funktioniert nicht
(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();
});
});})();