gpt4 book ai didi

php - 在 php 和 jquery 中添加行时出错?

转载 作者:行者123 更新时间:2023-12-01 08:14:22 25 4
gpt4 key购买 nike

<a class="checkModelButton" href="addrow.php">ADD ROW</a>
<table>
<thead>
<th>Name</th>
</thead>
<tboby id="model_row">
<tr>Nokia N70</tr>
</tbody>
</table>

和 jQuery:

jQuery('.checkModelButton').click(function(){
var url = jQuery(this).attr('href');
jQuery.ajax({
type:'get',
cache: false,
url: url,
success: function(html){
jQuery('#model_row').html(html);
}
});
});

在文件addrow.php

<tr>Nokia N71</tr>

当我点击标签时,结果是:

   <table>
<thead>
<th>Name</th>
</thead>
<tboby id="model_row">
<tr>Nokia N71</tr>
</tbody>
</table>

如何修复它的结果是:

   <table>
<thead>
<th>Name</th>
</thead>
<tboby id="model_row">
<tr>Nokia N70</tr>
<tr>Nokia N71</tr>
</tbody>
</table>

最佳答案

使用.append().appendTo()代替.html()

喜欢

success: function(html){
jQuery('#model_row').append(html);
}

或者

 success: function(html){
jQuery(html).appendTo('#model_row');
}

关于php - 在 php 和 jquery 中添加行时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11707220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com