我正在处理数据表,但无法使用响应填充数据表。没有显示错误。
HTML:
<table id="table" class="display responsive nowrap" cellspacing="0" width="100%">
<thead style="background-color:#303641;">
<tr>
<th>number</th>
<th>dateTimeStr</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
来自服务器的响应:
{"msg":null,"code":null,"status":null,"data":[{"number":"1234","dateTimeStr":null},{"number":"2345","dateTimeStr":null}],"draw":0,"limit":0,"recordsFiltered":0,"recordsTotal":0}
Java脚本代码:
function display(number, startdate, enddate, response) {
var cdrReqParams = {};
cdrReqParams.number = number;
cdrReqParams.fromDate = startdate;
cdrReqParams.toDate = enddate;
var jsonStr = JSON.stringify(cdrReqParams);
API.call("summary.json", 'POST', function(data) {
tableData = data.data;
createTable(tableData);
}, function(error) {
console.log(error);
}, jsonStr);
}
}
function createTable(tableData) {
console.log(tableData);
$('#table').DataTable({
"processing": true,
"serverSide": false,
"bFilter": false,
"pageLength": 100,
dom: 'Bfrtip',
buttons: ['colvis', 'print', 'csv', 'excel', 'pdf'],
searching: false,
language: {
buttons: {
colvis: 'Show/Hide Columns'
}
},
"aaData": tableData,
"aoColumns": [{
"mData": "number"
}, {
"mData": "dateTimeStr"
}]
});
}
此代码显示console.log(tableData)
值。但不会填入表格。任何想法,这里有什么不对?