我有一個(gè) DataTable,我試圖通過 ajax 調(diào)用加載數(shù)據(jù),但第一行數(shù)據(jù)總是說:“表中無可用數(shù)據(jù)”但是在它下面包含了加載的ajax數(shù)據(jù)。如何刪除無數(shù)據(jù)線并將ajax數(shù)據(jù)加載到該位置?代碼如下:<div class="box-body"> <table id="changeTicketsTable" class="table table-bordered table-striped"> <thead> <tr> <th>Ticket Number</th> <th>Description</th> <th>Risk</th> <th>Primary CI</th> <th>State</th> <th>Planned Start Date</th> <th>Actual Start Date</th> <th>Actual End Date</th> <th>Affected Partners</th> </tr> </thead> <tbody> </tbody> <tfoot> <tr> <th>Ticket Number</th> <th>Description</th> <th>Risk</th> <th>Primary CI</th> <th>State</th> <th>Planned Start Date</th> <th>Actual Start Date</th> <th>Actual End Date</th> <th>Affected Partners</th> </tr> </tfoot> </table></div>數(shù)據(jù)表的實(shí)現(xiàn):<script> getChangeTicketInformation(); $('#changeTicketsTable').DataTable({ "pageLength": 5, 'paging' : true, 'lengthChange': true, 'searching' : false, 'ordering' : true, 'info' : true, 'autoWidth' : false }); })</script>用于進(jìn)行 Ajax 調(diào)用的 Javascript:function getChangeTicketInformation(){ $.ajax({ type: "GET", url: "../../get_change_ticket_info", success: function(data) { $.each(data, function (i, item) { $('#changeTicketsTable').find('tbody').append( '<tr>' + '<td>' + item.number + '</td>' + '<td>' + item.short_description + '</td>' + '<td>' + item.risk + '</td>' + '<td>' + item.cmdb_ci_display_value + '</td>' + '<td>' + item.state + '</td>' + '<td>' + item.start_date + '</td>' + '<td>' + item.work_start + '</td>' + '<td>' + item.work_end + '</td>' + '<td>' + 'FILL IN' + '</td>' + '</tr>'); }); } });}
無法使用 Ajax 調(diào)用更新數(shù)據(jù)表的正文
繁星點(diǎn)點(diǎn)滴滴
2021-06-11 14:09:24