我正在嘗試以 JSON 格式從控制器操作中獲取一些數(shù)據(jù),然后使用 AJAX 將其發(fā)送到 DataTables,數(shù)據(jù)已顯示,但當(dāng)我搜索或排序數(shù)據(jù)時,數(shù)據(jù)消失并顯示“未找到數(shù)據(jù)”消息,也不再有任何頁面這只是一張長桌。HTML表格:<table id="demoGrid" class="table table table-hover dt-responsive nowrap" width="100%" cellspacing="0"> <thead> <tr class="styleHeaderTab"> <th class="th-sm"> Matricule </th> <th class="th-sm"> Intitulé </th> <th class="th-sm"> Nombre de compte </th> <th class=""> </th> </tr> </thead> <tbody id="chargeHolder"></tbody></table>腳本:$(document).ready(() => getActif());$('#demoGrid').dataTable({ "language": { "search": "Rechercher", "lengthMenu": "Afficher _MENU_ chargés par page", "info": "Page: _PAGE_ / _PAGES_", "paginate": { "next": "Suivante", "previous": "Précédente" } } });function getActif() { $.ajax({ url: '/ChargeAffaire/GetActif', method: 'get', dataType: 'json', error: (err) => console.log(err), success: (res) => { let s=""; for (let i=0;i<res.length;i++) { s +=`<tr> <td>${res[i].matricule}</td> <td>${res[i].intitule}</td> <td> 59</td>
從控制器操作獲取數(shù)據(jù)到 jquery 數(shù)據(jù)表
蕪湖不蕪
2021-08-20 15:00:08