问题
正在尝试从此数组中提取数据,该数组当前包含两个对象。我使用Tabletop.js从一个公开的谷歌电子表格中获取数据,在控制台中得到一个显示为ReferenceError: object is not defined的错误
控制台
[Object, Object]/*
*/0: Object
citation1url: "http://brandonsun.com"
citation2url: ""
citation3url: ""
datesaid: "2/20/2015"
explanation: ""
politicianname: "First Name, Last Name"
rowNumber: 1
statement: "This is my statement"
validity: "True, False, Unconfirmed"
*1: Object
citation1url: "http://andrewnguyen.ca"
citation2url: ""
citation3url: ""
datesaid: "2/20/2015"
explanation: ""
politicianname: "Andrew Nguyen"
rowNumber: 2
statement: "I work as a newsroom developer"
validity: "TRUE"scripts.js
$(function() {
window.onload = function() { init() };
var public_spreadsheet_url = "https://docs.google.com/spreadsheets/d/1glFIExkcuDvhyu5GPMaOesB2SlJNJrSPdBZQxxzMMc4/pubhtml";
function init() {
Tabletop.init( { key: public_spreadsheet_url,
callback: showInfo,
simpleSheet: true } )
}
function showInfo(data, tabletop) {
// alert("Successfully processed!")
console.log(data);
}
});发布于 2015-05-28 01:21:37
我不认为你已经在第二个函数showInfo中定义了数据。
我认为最好的方法是为你的桌面模型设置一个变量,比如
var tabletop = Tabletop.init( { key: public_spreadsheet_url, callback: function(data, tabletop) { console.log(data) }, simpleSheet: true });然后你就可以调用它了:
$("#myDiv").html(tabletop.data()[1].Statement);https://stackoverflow.com/questions/28636197
复制相似问题