Good day everyone! I am trying to append my ajax result in my datatable inside my modal. I already get the data that I needed but it still shows that data is not available.
It shows like this:
This is my ajax success which processed the result.
This is my HTML
Note: When I uncomment the "$('#viewTable').empty();" function it will remove my thead (Datatable).
Thanks!
It shows like this:
Mã:
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>'
);
});
Mã:
<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>
Thanks!