我有一个本地 json 文件
[{"image": "//www.dw.com/image/0,,18610867_301,00.jpg",
"link": "//www.dw.com/en/alcoa-splitting-up-amid-commodity-slump/a-18746568",
"heading": "Alcoa splitting up amid commodity slump"},
{"image": "//www.dw.com/image/0,,18742245_301,00.jpg",
"link": "//www.dw.com/en/kenya-ghetto-classics/a-18742091",
"heading": "Kenya Ghetto Classics"},
{"image": "//www.dw.com/image/0,,18045608_301,00.jpg",
"link": "//www.dw.com/en/rajoy-seeks-talks-after-catalonia-election-win/a-18746178",
"heading": "Rajoy seeks talks after Catalonia election win"},
{"image": "//www.dw.com/image/0,,18746472_301,00.jpg",
"link": "//www.dw.com/en/saudi-led-coalition-strikes-wedding-party-in-yemen-killing-scores-of-civilians/a-18746445",
"heading": "Saudi-led coalition strikes wedding party in Yemen, killing scores of civilians"}]
现在我想从另一个 javascript 文件中读取它并将信息呈现在一个漂亮的表格中。对于表 visuliztaion 我想使用敬业度.io 但问题是我无法读取 json 文件并按字面意思返回它我不需要更改数据我只需要读取数据并将其插入敏锐.io
我一直在尝试以下代码
$(document).ready(function() {
var data = $.getJSON('data/web_stories.json', function(data) {
dataStories = data
});
Keen.ready(function(){
var multipleEvents = {
"stories": data
}
// Send multiple events to several collections
client.addEvents(multipleEvents, function(err, res){
if (err) {
console.log('there is an error!')
}
else {
console.log('data sent')
}
});
但它似乎不起作用我收到以下错误: 400(错误请求)