title: AJAX xhr.responseText returns the whole html
body: <p>First I echo my datas in the php, I tried it with very simple ones, like:</p>
  
  <pre><code>echo json_encode(array("one" =&gt; "something"));
  </code></pre>
  
  <p>Then I try to catch it inside my ajax calling I previously wrote for that php (and is working):</p>
  
  <pre><code>succcess: function (xhr,data) {
          var something = JSON.parse(data);
                  console.log(something);
              }
  </code></pre>
  
  <p>But I get a syntax error for JSON.parse() everytime: </p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected token &lt; in JSON at position 0</p>
  </blockquote>
  
  <p>so I just logged out the <code>xhr.responseText</code> which the "data" is, and it returns the <strong>whole html</strong> of the page.</p>
  
  <p>If I log out the <strong>xhr</strong> (which should contain the html I think), I get this:</p>
  
  <blockquote>
    <p>XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0,
    withCredentials: false, upload: XMLHttpRequestUpload…}</p>
  </blockquote>
  
  <p>I would like to get back only the json encoded data, not the whole html. </p>
  
  <p>Thanks in advance for your answers.</p>
  
  <hr>
  
  <p>Edit: 
  The problem was that this php generated html content before the php statements, which was equal of echo statements, so the ajax couldn't distinguish it from the data I wanted to send. I made another php file to do this task and now it works properly.</p>