Reputation: 4187
<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>
And 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);
}
});
});
in file addrow.php
<tr>Nokia N71</tr>
When I click on a tag is result is:
<table>
<thead>
<th>Name</th>
</thead>
<tboby id="model_row">
<tr>Nokia N71</tr>
</tbody>
</table>
How to fix it to result is:
<table>
<thead>
<th>Name</th>
</thead>
<tboby id="model_row">
<tr>Nokia N70</tr>
<tr>Nokia N71</tr>
</tbody>
</table>
Upvotes: 1
Views: 97
Reputation: 31920
Use .append()
OR .appendTo()
instead of .html()
Like
success: function(html){
jQuery('#model_row').append(html);
}
OR
success: function(html){
jQuery(html).appendTo('#model_row');
}
Upvotes: 3
Reputation: 23064
Using .html()
will overwrite the content.
You need to append it.
$('#model_row').append(html);
Upvotes: 0