开发者

jQuery replaceWith(data) is not correctly doing his job

开发者 https://www.devze.com 2022-12-27 19:53 出处:网络
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.

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
                    $(开发者_如何学JAVA"#TOREPLACE").replaceWith(data).val( );
                 });  
            });


 }); 
</script>

The HTML :

    print '<div id="TOREPLACE">
<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>
</table>
</div>
</div>';

The PHP ajax echo :

print '

<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></table></div></div>';

Thanks


Ok, i finally found that the ID to replace was inside a PHP loop

i fixed that ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消