I'm trying the following to pull in a json formatted file into a JS variable (the json file is correct json).
var data;
$.getJSON('../data/data.js', function(json){
data = json;
});
console.log(data);
The result is:
undefined
When I console.log inside the $.getJSON
function I do get the results.
Any idea what I might be doing wrong?