Parsing or using variables from a called script?
<p>I have an AJAX function which loads content from a file and displays in the file that called it.</p>

<p>But the script that was called I want to loop an array which is actually set in the script that called it... this is main script that calls the file:</p>

<pre><code>function call_file(file, div_id) {
    var xmlhttp;
    if(window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
        if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
            document.getElementById(div_id).innerHTML = xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", file, true);
    xmlhttp.send();
}
var global = new Array();
global[0] = 1;
global[1] = 2;
call_script('html.html', 'main');
</code></pre>

<p>html.html is the file that is called which has this:</p>

<pre><code>&lt;script&gt;
    i = 0;
    for(var id in global) {
        alert(i + ' = ' + id);
        i++;
    }
&lt;/script&gt;
</code></pre>

<p>Is this at all possible?</p>
