title: XMLHttpRequest - JS not working on called page
body: <p>Have called another page through XMLHttpRequest. But the called page can't return JavaScript content. </p>
  
  <p>In below code it's not returning addition of 5+7.</p>
  
  <p>Have gone through various google stuff but nothing seems to be working.</p>
  
  <p>it would be helpful if anyone could crack that....</p>
  
  <blockquote>
    <p>request_xml.php</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;p id="demo"&gt;Here&lt;/p&gt;
  
  &lt;script&gt;
  
  window.onload = function() {
      loadDoc();
  };
  
  function loadDoc() {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        document.getElementById("demo").innerHTML = this.responseText;
      }
    };
    xhttp.open("GET", "call_page.php", true);
    xhttp.send();
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <blockquote>
    <p>call_page.php</p>
  </blockquote>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;p&gt;why is js not working?&lt;/p&gt;
  &lt;script&gt; 
      document.write(5+7);
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <blockquote>
    <p>Edit:</p>
  </blockquote>
  
  <p>JavaScript is working when page directly loaded</p>
  
  <p>Also, JS working inside onclick in <strong>call_page.php</strong></p>