jQuery replaceWith(data) is not correctly doing his job
- by Tristan
Hello,
i did a small ajax div refresh, but instead of replacing the values with the new ones, jquery adds the new data before the old ones.
What possibily causes that please ?
<script type="text/javascript">
$(document).ready(function(){
$('#AJAX').click(function(e){
e.preventDefault();
var hebergeur = $('#hebergeurJQUERY').val();
$.post("/statistiques/maj-bloc-commentaires.php", { hebergeur : hebergeur },
function(data){
// déclenchée seulement si succès
$("#TOREPLACE").replaceWith(data).val( );
});
});
});
</script>
The HTML :
print '<div id="a_remplacer">
<div class="detail_commentaires">
<table class="tableau_detail_commentaires">
<tr>
<td class="tab_space">Serveur <strong>'.$row['type'].'</strong></td>
<td>Qualite</td>
<td style="color:'.$c_vote.'">'.htmlentities($row['vote']).'</td>
</tr>
</div>
</div>
The PHP ajax echo :
print '<div id="a_remplacer"><div class="detail_commentaires" >
<table class="tableau_detail_commentaires">
<tr>
<td class="tab_space">Serveur <strong>'.$row['type'].'</strong></td>
<td>Qualite</td>
<td style="color:'.$c_vote.'">'.htmlentities($row['vote']).'</td>
</tr></div></div>
Thanks