javascript- can't pass values between two class instances
<p>I have defined one root object that I want to use as "namespace" for the rest of my classes. Inside this root object i have two classes - TOOLS and PRESENTATION. In PRESENTATION class i need to call one of public methods from TOOLS. As I can tell after playing with <code>console.log</code> in every step of execution of this code problem is that <code>return xhr.responseText</code> don't pass anything back to <code>tools.getData(configPath)</code> and I'm ending up with <code>undefined</code> in <code>console.log(pres.config)</code>.</p>

<p><strong>CODE:</strong></p>

<pre><code>// Create Namespace
var AppSpace = AppSpace || {}; 

// Class and Constructor
AppSpace.Tools = function() {

        //public methodts
        this.test = function(arg) {
            return arg                      
        }

        this.getData = function(path) {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', path, false);
            xhr.onreadystatechange = function() {
                if (xhr.readyState !== 4) return;
                if (xhr.status !== 0 &amp;&amp; xhr.status !== 200) {
                    if (xhr.status === 400) {
                        console.log("Could not locate " + path);
                    } else {
                        console.error("app.getData " + path + " HTTP error: " + xhr.status);
                    }
                    return;
                }
                return xhr.responseText;
              };
              xhr.send();
        } 

}


// Class and Constructor
AppSpace.Presentation = function(initName, initfPath){

        //private properties
        var configPath = initfPath || 'config.json';
        var configData = null;
        var name = initName || 'Unnamed Presentation';  

        //private methods
        var getConfigContent = function() {
            return tools.getData(configPath);
        }

        var getConfigData = function() {
            return JSON.parse(getConfigContent);
        }


        //public methodts


        //public properties
        this.name = null;
        this.config = null;
        this.debug = null;

        //logic
        this.name = name;
        this.config = getConfigContent();


}

//execution
var tools = new AppSpace.Tools();               
var pres = new AppSpace.Presentation('Some Name');

pres.debug = tools.test('value passed')
console.log(pres.debug);
console.log(pres.config);
console.log(pres.name);
</code></pre>

<p>Output in browsers console is:</p>

<pre><code>value passed js-oop.dev:99
**undefined js-oop.dev:100**
Some Name js-oop.dev:101
</code></pre>

<p>Can anyone give little advice on this? TIA.</p>
