title: Javascript AJAX include file witth eval
body: <p>Suppose I have </p>
  
  <p>1)
  a HTML document.</p>
  
  <p>2)
  This HTML document loads Javascript file "code.js" like this: </p>
  
  <pre><code>&lt;script src="code.js"&gt;
  </code></pre>
  
  <p>3)
  User clicks button which runs "fetchdata" function in "code.js",</p>
  
  <p>4)
  "fetchdata" function looks like this:</p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState==4) {
          myjsdata = xmlhttp.responseText;
      }
  }
  xmlhttp.open("GET", 'http://www.example.com/data.js', false);
  xmlhttp.send(null);
  </code></pre>
  
  <p>...</p>
  
  <p>Now how do I do the following successfully:</p>
  
  <p>I want to insert/eval my Javascript in a way, so all functions in "code.js" including "fetchdata" and functions defined above/below can access the data (structures, declarations, pre-calculated data values etc.) in "data.js". </p>
  
  <p>(If this was possible, it would be idea since I could wait loading the actual JS data file until the user explicitly requests it.)</p>