I have a function that, right now, retrieves a JSON file via AJAX call and prints out its contents on the console. However, I can't get it to read the file. I know that the location is formatted correctly, but the json
variable will always return a value of null
, indicating a nonexistent file.
function loadSettings(){
//loads setting list from mcc.json
var options = (function() {
var json = null;
$.ajax({
'async': false,
'global': false,
'url': "js/mcc.json",
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
console.log(options);
}
Did I do something wrong with my AJAX call?