I'm looking into dynamically using data from an external json file into my javascript. I must have misunderstood how to call the file because for the moment I can't even access the data... So theres my html calling the js file. and the js file calls the json using this method :
$(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();
});
I've taken this method right out of several tutorials I've read. How can I test if my json file is corrupted? Is it because I need to upload it on a server for it to work?
您可以通过将JSON文件粘贴到JSON Lint中来对其进行验证。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.