title: Load javascript files with ajax
body: <p>Just a simple question. (probably really basic I quess)</p>
  
  <p>Using XmlHttp I am able to load a page, but not sure how to iclude the js files..</p>
  
  <p>How can I alter the code in the images below, to be able to include the two java script files into the page loaded with ajax? I'm by far not a java script programmer, so really needs some help.</p>
  
  <p>Thank you.</p>
  
  <pre><code>clientside.php:
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
    &lt;script src="XmlHttp.js"&gt;&lt;/script&gt;
    &lt;script&gt;
      var urlServer ="serverside.php";
      var xmlObj = null;
  
      function callServer(urlServer){
        xmlObj= XmlHttp.create();
            if(xmlObj) {
              xmlObj.onreadystatechange = responseFromServer;
              xmlObj.open("GET", urlServer, true);
              xmlObj.send();
            }
      }       
  
      function responseFromServer() {
        if (xmlObj.readyState == 4) {
          if (xmlObj.status == 200) {
            document.getElementById("main").innerHTML = xmlObj.responseXML.getElementsByTagName("mybody")[0].firstChild.nodeValue;
            eval(xmlObj.responseXML.getElementsByTagName("myscript")[0].firstChild.nodeValue);                
          }
        }
      }   
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="main"&gt;&lt;/div&gt;
    &lt;input type="button" value="Begin test" onClick="callServer(urlServer)"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  
  serverside.php :
  
  &lt;?php
    //How do I load these two javascript files together with the &lt;body&gt; below.
    //Obviously the method below does not work..
    $script="
     &lt;script type='text/javascript' src='SlimBox/js/mootools.js'&gt;&lt;/script&gt;
     &lt;script type='text/javascript' src='SlimBox/js/slimbox.js'&gt;&lt;/script&gt;
    ";
  
    $body="
      &lt;body&gt;
      &lt;a href='img/facebook-icon.png' rel='lightbox[roadtrip]' cap='test'&gt;&lt;img alt=''border='0' src='img/facebook-icon.png' /&gt;&lt;/a&gt;
      &lt;/body&gt;
    ";
  
    //Now build the xml page:
    $xml = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;";
    $xml .= "&lt;mypage&gt;";
    $xml .= "&lt;myscript&gt;".htmlentities($script)."&lt;/myscript&gt;";
    $xml .= "&lt;mybody&gt;".htmlentities($body)."&lt;/mybody&gt;";
    $xml .= "&lt;/mypage&gt;";
    header('Content-type: text/xml');
    echo $xml;
  ?&gt;
  </code></pre>