使用Tabletop.js,尝试从数组中获取数据
Using Tabletop.js, trying to fetch data from array
问题
正在尝试从此数组中获取数据,该数组当前包含两个对象。我正在使用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);
}
});
我认为您没有在第二个函数showInfo中定义数据。
我认为最好的方法是为你的桌面模型制作一个变量,比如
var tabletop = Tabletop.init( { key: public_spreadsheet_url, callback: function(data, tabletop) { console.log(data) }, simpleSheet: true });
然后你可以称之为:
$("#myDiv").html(tabletop.data()[1].Statement);
相关文章:
- 从json子数组获取数据
- 从javascript数组获取php的日期时间
- 从表中的 JSON 数组获取数据
- 每个表的2D数组获取坐标JTSL,JAVASCRIPT
- javascript从元素到数组获取文本
- 如何从数组获取链接以在youtube Iframe API中播放
- JSON 编码多维数组获取值
- 如何从两个 JSON 数组获取增量
- 通过单击按钮数组获取隐藏 html 元素值的当前数组
- 在 JavaScript 中从内部数组获取数据
- 从数组获取非重复索引在 0 时失败
- JavaScript 从对象中的数组获取数组
- 如何通过 ajax 将 php 数组作为 javascript 数组获取
- 快速从 2D 数组获取索引,无需迭代 jquery
- 从 Nodejs socketio 数组获取所有套接字 id
- 无法动态从 json 数组获取数据
- 如何在javascript中使用数组获取和设置html标签的值
- jQuery对象数组获取一个项作为jQuery对象
- 如何在不向输出数组获取空值的情况下拆分字符串
- 从输入到数组获取数据