title: Why is my XML http request returning HTML instead of JSON?
body: <p>I need to obtain the JSON response text from a web page in order to parse it. However, when I create my XML HTTP request, I get HTML returned that's not even from the page I've requested. </p>
  
  <p>I've verified that the content-type is set to application/json, required  xmlhttprequest instead of xhr2 (did not work), set XMLHttpRequest.responseType to "json", and more. I tried a different url (<a href="https://jsonplaceholder.typicode.com/todos/1" rel="nofollow noreferrer">https://jsonplaceholder.typicode.com/todos/1</a>) and I'm able to obtain my JSON response text. However, with my "secret URL" (unable to provide unfortunately), I get an HTML response. </p>
  
  <p>I'm not sure where I get the HTML from, I looked on SauceLabs, but it fails at this point. I also tried browser.getURL(), but I get a </p>
  
  <pre><code>function myXMLRequest() {
  
    var XMLHttpRequest = require('xhr2');
    XMLHttpRequest.responseType = "json";
    var xmlhttp = new XMLHttpRequest(); 
    // this URL works, but my secret URL does not
    var url = "https://jsonplaceholder.typicode.com/todos/1";
  
    xmlhttp.onreadystatechange = function() {
      console.log("this.readyState: " + this.readyState + " 
      this.status: " + this.status);
    if (this.readyState === 4 &amp;&amp; this.status === 200) {
        console.log("this.responseText: " + this.responseText);
    } else {
        console.log("I was not ready");
    }
    };
        xmlhttp.open("GET", url, true);
        xmlhttp.send();
      }
  </code></pre>
  
  <p>In the URL that works, I get a response text like:</p>
  
  <pre><code>{
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
  }
  </code></pre>
  
  <p>I would like my secret URL to obtain a response like this. Currently it obtains an HTML response, as can be seen from my image.</p>
  
  <p><a href="https://i.stack.imgur.com/LzIJf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LzIJf.png" alt="HTML response"></a></p>