I'm hanging dry here. The user clicks on an option on a select list, then jQuery sends an xhr to the server to process, nothing special here, code works perfectly (firebug shows correct Posted data).
Then a simple code to return rows from a database where W_id == $val, and then fetch results in $result, then echo results as a json response:
public function getCities($val) {
    $sth = $this->db->prepare("SELECT id, name FROM cities WHERE w_id = :w_id");
    $sth->execute(array(':w_id' => $val));
    $result = $sth->fetchAll(PDO::FETCH_ASSOC);
    //print_r($result);
    header("content-type:application/json");
    echo json_encode($result);
}
Firebug shows the Post data but no Response. But when I uncomment the print_r, it shows me an array as a Response:
Array(
    [0] => Array(
        [id] => 1401
        [name] => Aïn Bouchekif
    )
    [1] => Array(
        [id] => 1402
        [name] => Aïn Deheb
    )
    [2] => Array(
        [id] => 1403
        [name] => Aïn El Hadid
    ) and so on...
Which means that there are results that can be returned, but I don't know how to jsonify them. Any help is appreciated, thanks.
 
     
    