title: Junk after document element. How to avoid XML parsing with ajax get (XMLHttpRequest) in vanilla javascript?
body: <p><a href="https://stackoverflow.com/questions/6084978/firefox-ajax-junk-after-document-element">Firefox &amp; AJAX Junk after document element</a></p>
  
  <p>I'm having pretty much the exact same problem as the above question, but for different reasons.</p>
  
  <p>To reiterate the problem:</p>
  
  <p>I have some html file:</p>
  
  <pre><code>&lt;style&gt; #hat { color: red; } &lt;/style&gt;
  &lt;script&gt; var hat = "fez"; &lt;/script&gt;
  </code></pre>
  
  <p>Which I'm retreiving via vanilla ajax call:</p>
  
  <pre><code>var request = new XMLHttpRequest();
  request.open('GET', target, true);
  
  request.onload = function() {
      if (request.status &gt;= 200 &amp;&amp; request.status &lt; 400) {
          // Success!
          var response = request.responseText;
      } else {
          // We reached our target server, but it returned an error
      }
  };
  
  request.onerror = function() {
     // There was a connection error of some sort
  };
  
  request.send();
  </code></pre>
  
  <p>That is throwing an error in console:</p>
  
  <p><code>junk after document element</code></p>
  
  <p>I don't want the html file parsed at all.  I've tried searching for a non XML HttpRequest method, but JQuery is all I can find on the subject.  Perhaps there is something like a TextHttpRequest that just retrieves text without parsing it?  Or maybe there's a way to tell an XMLHttpRequest that parsing is unnecessary?</p>
  
  <p>This all seems like it should be pretty obvious, but I just keep finding tutorials on ajax that use jquery.</p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#open%28%29" rel="nofollow noreferrer">Here's a link to the MDN</a></p>