loading js file within js
<p>i have code like this: <a href="http://stackoverflow.com/questions/1618351/loading-js-files-dynamically-via-another-js-file">loading js files dynamically via another js file?</a> but it fails to recognize the object within.</p>

<p>ie. content of cCB.js</p>

<pre><code>cCB = {

    map: {},
    ...
}
</code></pre>

<p>etc.</p>

<p>using:</p>

<pre><code>function jsinclude(file) {
    var script  = document.createElement('script');
    script.src  = file;
    script.type = 'text/javascript';
    script.defer = false;
    document.getElementsByTagName('head').item(0).appendChild(script);
}
</code></pre>

<p>with the calling code:</p>

<pre><code>jsinclude('/js/cCB.js');
</code></pre>

<p>produces in  my html head</p>

<pre><code>&lt;script src="/js/cCB.js" type="text/javascript"&gt;&lt;/script&gt;
</code></pre>

<p>but at the first call to a var within that object:</p>

<pre><code>cCB.map = new google.maps.Map(document.getElementById('map'), myOptions);
</code></pre>

<p>i get error:</p>

<pre><code>referenceError: can't find variable cCB
</code></pre>

<p>========
have I missed something silly here? I have searched already (hence the link) but have no answer</p>
