0
我想通過ajax嘗試使用datatables.net進行分頁。如何在ajax中使用datatables
我具有發送開始日期和結束日期和以下2個輸入字段是表結構
<table class="table table-hover" id="example">
<thead>
<tr>
<th>Loan ID</th>
<th>Date</th>
<th>Loan Amount</th>
<th>Loan Type</th>
</tr>
</thead>
<tbody id="amount"></tbody></table>
按鈕被點擊時,我調用此函數
$('#recv').click(function(){
var fromDate=$('#from').val();
var toDate=$('#to').val();
var test=$.ajax({
type: "GET",
url: "/project/getDetails",
data:{"fromDate":fromDate,"toDate":toDate},
dataType:"json",async:false
}).responseText;
var result = eval('('+test+')');
$('#example').dataTable({
"bServerSide": true,
"sAjaxSource": result,
"bProcessing": true,
"aoColumns": [
{ "sName": "Loan_ID",
"bSearchable": false,
"bSortable": false
},
{ "sName": "Date" },
{ "sName": "Loan_Amount" },
{ "sName": "Loan_Type" }
]
});
當過我點擊按鈕,然後我得到錯誤警告框說datatables警告id =示例ajax錯誤
可以任何身體請告訴我如何解決?
感謝您的回答,但它給了我error.When頁面加載,然後還它給我的錯誤,說Ajax錯誤 – rocking 2014-11-24 12:17:30
你刪除或註釋掉原密碼? – markpsmith 2014-11-24 12:22:43
是的,我已經刪除了我的舊代碼 – rocking 2014-11-24 12:22:57