I am trying to get data from Json file with getJson function:
$.getJSON( "uploads/data.json" ).then(function(data) {
allData = data.sculptures;
locations = {};
for(var i=0; i<data.location.length; i++) {
locations[data.location[i].name] = data.location[i].location;
}
console.log(allData);
console.log(locations);
});
But I am not getting anything. When I ran this code in Chrome console developer tool, it only shows this:
Object {}
always: ()
done: ()
fail: ()
pipe: ()
progress: ()
promise: (a)
state: ()
then: ()
__proto__: Object
This is data.json:
{"sculptures":[{"title":"Bust of Caracalla","location":"Paris"},
{"title":"Brutus The Younger","location":"Paris"}],
"location":[{"name":"Beaux-Arts in Dijon, France","location":{"lat":47,"lng":5}},
{"name":"Louvre, Paris","location":{"lat":48,"lng":2}},
{"name":"St Pauls Cathedral, London","location":{"lat":51,"lng":-0}},
{"name":"V&A, London","location":{"lat":51,"lng":-0}}]}