我想在Ajax成功上初始化DataTable。它第一次正常工作,但不會再工作,除非我刷新頁面。DataTable警告 - 無法重新啓動DataTable
JS功能:
this.summaryReport = function()
{
crsf = $("input[name=csrftestname]").val();
searchClients = $("#searchClients").val();
$('#loadingmessage').show();
$.ajax({
url: url+"query_report_summary",
type: "post",
cache: false,
data: {"csrftestname": crsf, searchClients: searchClients},
success: function(query_result)
{
var data = $.parseJSON(query_result);
$('#example').DataTable({
data: data,
columns: [
{ data: "name" },
{ data: "location" },
{ data: "source" },
{ data: "contact" },
{ data: "number" },
{ data: "status" }
]
});
self.reportSummary(data);
},
complete: function()
{
$("#reportSummaryForm")[0].reset();
$('#loadingmessage').hide();
}
});
}
錯誤我得到的 - 數據表警告 - 無法初始化數據表。
HTML:
<form role="form" class="" id="reportSummaryForm">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
<div class="input-group input-group-sm">
<input class="form-control input-sm" type="text" id="searchClients" name="searchClients" placeholder="">
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary" data-bind="click: summaryReport">Search</button>
</span>
</div>
</form>
<table id="example" class="display" width="100%"></table>
你有關於「重新初始化」的含義任何線索? – DKSan