【发布时间】:2016-06-09 23:07:07
【问题描述】:
我使用的是 jquery 1.7.1,因为这是我的旧项目,所以我无法更改它。我在将控制器返回的 json 数据设置为 javascript 对数据表进行的 ajax 调用时遇到问题。 以下是我的ajax调用
$.ajax({
type : "post",
url : "myController",
dataType : 'json',
data : 'operation=getUploaded&filename=' + filename,
success : function(data) {
console.log("<<<<<<<<<<<data<<<<<<<<<<<", data.Data[0]);
$('#example').dataTable({
"aoData": data.Data[0],
"aoColumns": [
{ "mDataProp": "id" },
{ "mDataProp": "point" },
{ "mDataProp": "floor" },
{ "mDataProp": "custAccNo" },
{ "mDataProp": "data" }
]
});
}
});
这是我返回的 json:
{
"Data": [{
"id": 4534534,
"point": "45",
"floor": "345",
"custAccNo": "000000001",
"data": "ABC",
"fileName": "23rbc.rti",
"grid": "001"
}]
}
这是我的 jsp 中的表格:
<div class="container">
<table cellpadding="0" cellspacing="0" border="0" class="dataTable" id="example">
<thead>
<tr>
<th>id</th>
<th>point</th>
<th>floor</th>
<th>custAccNo</th>
<th>data</th>
</tr>
</thead>
</table>
</div>
有什么建议吗?
【问题讨论】:
-
您遇到错误了吗?请发布您面临的确切问题。
-
空数据表显示,没有错误。 @Hector
-
正确的设置是
aaData,而不是aoData...
标签: jquery json ajax datatables