calling an object from different files
<p>I'm facing a problem when I call an object from different files.</p>

<pre><code>function node(id, content, prev, next){
    this.id = id;
    this.prev = prev;
    this.next = next;
    this.content = content;
}
</code></pre>

<p>I'm using this code to load the external file in case if the object is not defined before.</p>

<pre><code>function callNode(node){
    if(typeof(node) === 'undefined')
    {   
        path = "js/tree/t2.js";
        $.getScript(path, function(){
            console.log('done');
            for(i in node)
            alert(node[i]);
        });
    }
    else alert('node exist');
}
</code></pre>

<p>in the t2.js i have the following:</p>

<pre><code>n1 = new node('text1','n1');
n2 = new node('text2','n2');
n3 = new node('text3','n3');

n2.next = n3;
n2.prev = n1;
</code></pre>

<p>the html code:</p>

<pre><code>&lt;button onclick="callNode(n2)"..
</code></pre>

<p>but it keeps giving me undefined object</p>
