【发布时间】:2013-05-21 17:30:22
【问题描述】:
我正在研究动态地将外部 json 文件中的数据用于我的 javascript。 我一定误解了如何调用文件,因为目前我什至无法访问数据...... 所以我的 html 调用了 js 文件。并且js文件使用这种方法调用json:
$(function() {
function stockTimeline(){
$.getJSON('json/corse_timeline/corse_timeline.json', function(donnees) {
$('#wrap').html('<p>' + donnees.timeline.date[4].endDate + '</p><p>' + donnees.timeline.date[9].startDate + '</p><p>' + donnees.timeline.headline + '</p><p>' + donnees.timeline.date[30].headline + '</p><p>');
console.log("this console.log IS NOT working");
});
console.log("this console.log IS working");
}
stockTimeline();
});
我从阅读过的几个教程中直接采用了这种方法。 如何测试我的 json 文件是否已损坏? 是因为我需要将它上传到服务器上才能使用吗?
【问题讨论】:
-
控制台是否显示任何 javascript 错误?
标签: javascript jquery ajax json load