JSON renvoy� depuis PhP par Ajax illisible
Bonjour tout le monde,
Je rencontre un gros probl�me avec JSON et ses amis PhP, SQL, JS-Ajax.
Voici le code JS en premier avec mon appel � PhP par Ajax :
Code:
1 2 3 4 5 6 7 8 9 10 11
| var xhr = getXhr();
xhr.open( 'post' , 'php/gestview.php' , true );
xhr.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
xhr.onreadystatechange = function() {
if ( xhr.readyState == 4 && xhr.status == 200 ){
var PhP_reply = xhr.responseText;
var poutou = JSON.parse(PhP_Reply);
alert(poutou);
}
}
xhr.send( null ); |
Puis le script PhP qui re�oit la requ�te Ajax affich�e ci-dessus :
Code:
1 2 3 4 5 6 7 8 9 10 11
| try{
$bdd = new PDO ('mysql:host=localhost;dbname=db_application', 'root', '');
}
catch (Exception $e){
die('Erreur : ' . $e->getMessage());
}
$query_liste_clients = $bdd->query('SELECT * FROM fiches_clients ORDER BY id_client ASC');
$bdd = null;
$mareq = $query_liste_clients->fetchAll();
$ajax_retour = json_encode($mareq);
echo $ajax_retour; |
Voil� une journ�e que je cherche, que j'interroge et RIEN ! Y'a-t-il un bon samaritain ?
M�me si je comprends parfaitement ce qu'il se passe, il me manque une syntaxe, bref du code... Quelqu'un voit ?
Merci d'avance.