[AJAX] comment afficher un table récupérer depuis ajax ?
Bonjour, je récupère depuis un ajax un post:
Code:
1 2 3 4
|
<div id="reponse">
</div> |
Code:
1 2 3 4 5 6 7 8 9 10 11
| var ajax = getXmlHttpRequest();
ajax.open('POST','retour.php',true);
ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ajax.send('nom=toto&&sexe=m');
ajax.onreadystatechange = function(){
if(ajax.readyState == 4 && ajax.status == 200)
{
alert(ajax.responseText);
}
};
ajax.send(null); |
comment je dois faire pour afficher cette table dans ma div reponse ?
voici retour.php
Code:
1 2 3 4 5 6 7 8 9 10
| <?php
echo '<table>';
echo '<tr>';
echo '<td>'.$_POST['nom'].'</td>';
echo '<td>'.$_POST['sexe'].'</td>';
echo '</tr>';
echo '</table>';
?> |
alert(ajax.responseText); me donne bien la réponse sous form html
mais rien n'affiche
Code:
1 2 3 4 5 6
| if(ajax.readyState == 4 && ajax.status == 200)
{
var tb_reponse = ajax.responseText;
}
};
ajax.send(null);document.getElementById('reponse').innerHTML= tb_reponse; |
merci d'avance pour le conseille :)