How to access object from within listener function in JS
<p>I want to access <strong>foo.settings.debug</strong> object from inside the <strong>success</strong> listener of the <strong>require()</strong> function.  I keep getting an undefined error and when I reference "this" it ends up referencing the ajax object.  Please assist.</p>

<pre><code>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);
            }
        });

    }
}
</code></pre>
