我有以下JSON:
[{"page_title":"SaSaZu Club","page_url":"sasazu"},{"page_title":"Karlovy l\u00e1zn?","page_url":"karlovy-lazne"},{"page_title":"James Dean","page_url":"james-dean"},{"page_title":"Club Lavka","page_url":"club-lavka"},{"page_title":"TRETTER'S Cocktail Bar.","page_url":"tretters-cocktail-bar"}]
我的Ajax将TR添加到表中:
$(document).ready(function () {
$("#category").change(function () {
var category = $('#category option:selected').val();
$.ajax({
type: "GET",
url: '/administrator/page/get_page_by_category',
data: {'category': category},
async: true, //Hey browser! run the code
//if we prased data run:
success: function (data) {
var obj = JSON.parse(data);
var trHTML = '';
$.each(obj, function (i, item) {
trHTML += '<tr><td>' + item.page_title + '</td><td>' + item.page_url + '</td></tr>';
});
$('#records_table').append(trHTML);
}
});
});
});
工作正常,但每次我使用$category
并更改值。新值只是在现有的顶部,我想在那里单独显示每个TR ..我想我应该只使用其他东西然后&#34;追加?&#34;