title: Ajax returning html instead of JSON
body: <p>well I know it must look like a beginner question and I do hope I've missed something easy but I can't seem t find what...</p>
  
  <p>I am trying to get a JSON type back but I only get the html code in return.</p>
  
  <p>Here is my code, I'm not really a beginner but I am far from being a pro so I tried some testing. If i put dataType it throws me an error, even though now my code looks like this :</p>
  
  <pre><code>$("#search_ref").click(function(){
      var ref_article = $("#ref_article").val();
      $("#search_buttons").append('&lt;button id="new_search" type="button" class="btn btn-warning"&gt;&lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt; Nouvelle recherche&lt;/button&gt;');
      $("#search_ref").remove();
      $(".construct_delete").remove();
      nb_elements = 1;
      size = 20;
      $.ajax({
          url : 'search_ref.php',
          type : 'POST',
          data : 'ref_article=' + ref_article,
          success : function(response){
              alert(response);
              console.log(response);
              var table_construct = JSON.parse(response);
              alert(table_construct);
          },
          error : function(){
              alert("Error durant \"search_ref\"");
          }
      });
  })
  </code></pre>
  
  <p>And the other part:</p>
  
  <pre><code>&lt;? 
  
  $banane = [1, 2, 3, 4 ];
  $banane = json_encode($banane);
  echo $banane;
  
  ?&gt;
  </code></pre>
  
  <p>This is not my final code but I don't get why this isn't working, how can I force the JSON data instead of the html ?</p>
  
  <p>Here is what I tried : dataType:JSON, setting the second php page doctype to JSON ?, </p>
  
  <p>The message of the alert is this now:</p>
  
  <p><br />
  
  ( ! ) Parse error: syntax error, unexpected '$banane' (T_VARIABLE) in C:\wamp64\www\StageNeyret\search_ref.php on line <i>5</i>
  </p>