我有一个 DataTable,我试图通过 ajax 调用加载数据,但第一行数据总是说:“表中无可用数据”但是在它下面包含了加载的ajax数据。如何删除无数据线并将ajax数据加载到该位置?代码如下:<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>数据表的实现:<script> getChangeTicketInformation(); $('#changeTicketsTable').DataTable({ "pageLength": 5, 'paging' : true, 'lengthChange': true, 'searching' : false, 'ordering' : true, 'info' : true, 'autoWidth' : false }); })</script>用于进行 Ajax 调用的 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>'); }); } });}
添加回答
举报
0/150
提交
取消