【发布时间】:2018-10-01 12:46:51
【问题描述】:
大家好!我正在尝试将我的 ajax 结果附加到我的模式内的数据表中。我已经得到了我需要的数据,但它仍然显示数据不可用。
这是我处理结果的 ajax 成功。
success: function(result)
{
//console.log(result);
//$('#viewTable').empty();
$.each(result, function(index, value){
console.log(value);
$('#viewTable').append(
'<tbody>' +
'<tr>' +
'<td>' + value.qr_code + '</td>' +
'<td>' + value.reference_no + '</td>' +
'<td>' + value.brand_name + '</td>' +
'<td>' + value.model_name + '</td>' +
'<td>' + value.unitPrice + '</td>' +
'</tr>' +
'</tbody>'
);
});
这是我的 HTML
<table id="viewTable" class="table table-striped">
<thead>
<tr>
<th>Barcode</th>
<th>Reference Number</th>
<th>Brand Name</th>
<th>Model Name</th>
<th>Unit Price</th>
</tr>
</thead>
</table>
注意:当我取消注释“$('#viewTable').empty();”时函数它将删除我的thead(数据表)。
谢谢!
【问题讨论】: