2 回答

TA貢獻1824條經(jīng)驗 獲得超6個贊
我的代碼中有這個錯誤;當已經(jīng)初始化所選節(jié)點的DataTable實例時,通過將選項傳遞給Dataatables構(gòu)造函數(shù)對象來觸發(fā)。你應(yīng)該使用像:
$('#example').dataTable( {
paging: false} );
在您的代碼中只有 1 次。

TA貢獻2037條經(jīng)驗 獲得超6個贊
function show_categories(){
$.ajax({
type : 'ajax',
url: base_url + 'Admin/Categories/fetch_categories',
async : true,
dataType : 'json',
success : function(data){
var html = '';
var i;
for (i = 0; i < data.length; i++) {
html += '<tr>' +
'<td>' + data[i].category + '</td>' +
'<td style="width:80px;">' +
'<button type="button" class="btn btn-xs btn-info" data-category_id="' + data[i].category +'"><em class="fas fa-edit"></em></button> '+
'<button type="button" class="btn btn-xs btn-danger" data-category_id="' + data[i].category +'"><em class="fas fa-trash"></em></button>'+
'</td>' +
'</tr>';
}
$('#category_showData').html(html);
}
});
}
<table id="category_dataTables" class="table table-bordered table-sm table-hover datatable dt-responsive nowrap">
<thead>
<tr>
<th>Category</th>
<th>Action</th>
</tr>
</thead>
<tbody id="category_showData">
</tbody>
</table>
- 2 回答
- 0 關(guān)注
- 330 瀏覽
添加回答
舉報