title: Why doesn't the php array convert to JSON?
body: <p>I am reading data from the mysql database and i am saving them into an array which looks like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; aargau
      [1] =&gt; appenzell_au
      [2] =&gt; appenzell_in
      [3] =&gt; basel-land
      [4] =&gt; basel-stadt
      [5] =&gt; bern
      [6] =&gt; freiburg
      [7] =&gt; genf
      [8] =&gt; glarus
      [9] =&gt; graub�nden
      [10] =&gt; jura
      [11] =&gt; luzern
      [12] =&gt; neuenburg
      [13] =&gt; nidwalden
      [14] =&gt; obwalden
      [15] =&gt; obwalden
      [16] =&gt; schwyz
      [17] =&gt; solothurn
      [18] =&gt; st_gallen
      [19] =&gt; tessin
      [20] =&gt; thurgau
      [21] =&gt; uri
      [22] =&gt; waadt
      [23] =&gt; wallis
      [24] =&gt; zug
      [25] =&gt; z�rich
  )
  </code></pre>
  
  <p>THE CODE (client.class.php) THAT DOES THIS LOOKS LIKE THIS :</p>
  
  <pre><code>public function getCantons($country){
          $cantonsArray= array();
      //  $tmpArray = array();
          $sql_get_cantons = sprintf("SELECT name FROM locations WHERE country='".$country."'");
          $result = $this-&gt;CONNECTION-&gt;query($sql_get_cantons);
          while($row = mysqli_fetch_array($result)){  
              array_push($cantonsArray,$row['name']);
          }
          return $cantonsArray;
      }
  </code></pre>
  
  <p>I HAVE AN OTHER PHP FILE (server.php) which returns the answer to the ajax call</p>
  
  <pre><code>if($_POST['command']=='cantons'){
          $country = $_POST['country'];
          $client = new Client();
         // $results = $client-&gt;getActiveItemsOfCategory('technology');
          $results = $client-&gt;getCantons($country);
          $jsonResults = json_encode($results);
          print_r($jsonResults);
      }
  </code></pre>
  
  <p>IN THE AJAX CALL (which is working properly becauseI use I use the same code as in other AJAX calls) I simply do this :</p>
  
  <pre><code> var jqxhr = $.post( "php/server.php", {country:COUNTRY,command:'cantons'},function() {
  
  })
    .done(function(data) {
          console.log(data);
     })
    .fail(function(data) {
       alert(JSON.stringify(data));
    })
    .always(function() {
  
  });
  </code></pre>
  
  <p>THE result is empty </p>