title: Retrieving source code using XMLhttpRequest in javascript
body: <p>I am trying to get the source code of a website by using XMLhttpRequest in javascript, but I cannot get the response. How do I get source code using XMLhttpRequest? Here is what I have right now:</p>
  
  <pre><code>&lt;script language="Javascript" type="text/javascript"&gt;
  var req = new XMLHttpRequest();
  req.open(
      "GET",
      "http://www.google.com",
      true);
  req.onreadystatechange = statusListener;
  req.send(null);
  
  function statusListener()
  {
  if (req.readyState == 4) 
      {
          var docx=req.responseXML;
          alert(docx);
      }
  }
  &lt;/script&gt;
  </code></pre>