I am looping over a number of json files in a directory called "trips" and would like to output data from each file in the front end. However I keep getting errors "Syntax Error: Unexpected token :". Every page I've found related to this topic seems to point to the json files being improperly formatted but these ones definitely are not. For some reference this is the format of each file
{
"start_time": some time,
"coords": [some array of coords],
"end_time": some time
}
Here is my code where I try to access the data from each json file:
$(document).ready(function() {
console.log("Start jsTrips");
$.each(jsTrips, function(k, v) {
var weblink = "http://localhost:8080/trips/" + v;
console.log("GET " + weblink);
weblink += "?callback=?"
$.ajax({
url: weblink,
dataType:"jsonp",
success:function(data){
$("." + k).html(data.start_time);
}
});
});
console.log("Finished");
});
If you need more details than this let me know.
Thanks everybody!!