【发布时间】:2015-12-01 15:57:15
【问题描述】:
我想使用此 Google 表格中的数据以 HTML 格式显示酒店列表: https://docs.google.com/spreadsheets/d/1pksFEATRRWfOU27kylZ1WLBJIC-pMVxKk9YlCcDG0Kk/
我正在使用 JSON 和 jQuery,并希望使用 jQuery 循环遍历所有行,以 HTML 格式显示它们。
到目前为止,我已经设法使用 JSON 显示一些内容,但我不确定如何继续显示所有行: 代码笔:http://codepen.io/aljohnstone/pen/adobow
$.getJSON('http://cors.io/?u=https://spreadsheets.google.com/feeds/list/1pksFEATRRWfOU27kylZ1WLBJIC-pMVxKk9YlCcDG0Kk/od6/public/values?alt=json',function(data){
//remove http:// for a text
var url = data.feed.entry[0]['gsx$url']['$t'];
var shortUrl = url.replace('http://', '');
//give id's google sheet values
$('#bandb').text(data.feed.entry[0]['gsx$name']['$t'])
$('#description').text(data.feed.entry[0]['gsx$description']['$t'])
$('#image').attr("src", (data.feed.entry[0]['gsx$image']['$t']));
$('#link').text(shortUrl).attr("href", (data.feed.entry[0]['gsx$url']['$t']));
});
【问题讨论】:
标签: javascript jquery html json