I want to access foo.settings.debug object from inside the success listener of the require() function. I keep getting an undefined error and when I reference "this" it ends up referencing the ajax object. Please assist.
var foo = {
info: {
version: '0.0.1'
},
settings: {
debug: true
},
require: function(script) {
$.ajax({
url: script,
dataType: "script",
async: false,
success: function(){
if(foo.settings.debug) console.log('loaded js file: ' + script);
},
error: function(){
throw new Error("Could not load script " + script);
}
});
}
}