title: Ajax call to PHP only returns "status 200 OK" but no array with database results?
body: <p>I make an AJAX call to a php file that uses PDO to connect to mysql, and I print the result to the console, but the only result displayed is:</p>
  
  <pre><code>Object {readyState: 4, responseText: "", status: 200, statusText: "OK"}
  </code></pre>
  
  <p>The same call works with msqli and the json with the results is displayed, what am i doing wrong?</p>
  
  <p>Here is the code:</p>
  
  <p>custom js:</p>
  
  <pre><code> /*eslint-env jquery, browser*/
  $(document).ready(function(){
  
  $("#botono").click(function(){
  
      $.ajax({
          type: 'GET',
          url: 'phpf/retraerClientes.php',
          dataType: 'json',
          contentType: 'application/json; charset=utf-8',
          success: function(response) {
              console.log(response);
          },
          error: function(error) {
              console.log(error);
          }
      });
  
   });
  
  });
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>ini_set('display_errors', 1); 
  error_reporting(E_ALL);
  
  define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) &amp;&amp; strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); 
  if(!IS_AJAX) {die('');}
  
  $configs = include('config.php');
  
   try{
  
  $conn = new      PDO("mysql:host=".$configs["host"].";dbname=".$configs["database"],$configs["use    rname"],$configs["password"]);
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  $sql = "SELECT * FROM prueba";
  $results = $conn-&gt;query($sql)-&gt;fetchAll(PDO::FETCH_ASSOC);
  $jsonFinal = json_encode($results);
  echo $jsonFinal;
  
  }catch(PDOException $ex){
      echo 'Connection With Database Failed: '.$ex-&gt;getMessage();
  }
  </code></pre>
  
  <p>UPDATE:
  i found the answer: </p>
  
  <pre><code>$accents = $conn-&gt;query("SET NAMES 'utf8'"); 
  </code></pre>
  
  <p>that line was missing, my records had accents, that made the final json corrupt and created a false positive</p>