我的问题与建议的问题无关。
{
"aaData": [
{
"id": "1",
"reg_d": "2017-09-15 10:15:57",
"fname": "Vishwas",
"lname": "Jadav",
"email": "vjadav@live.com"
},
{
"id": "50",
"reg_d": "2017-09-20 14:33:59",
"fname": "testA",
"lname": "testk",
"email": "test5@gmail.com"
},
{
"id": "51",
"reg_d": "2017-09-20 14:36:18",
"fname": "mvjh",
"lname": "kgjk",
"email": "teesth@jhk.com"
}
],
"draw": 5,
"recordsTotal": 35,
"recordsFiltered": 5
}
我使用的代码是:
<script type="text/javascript">
$(document).ready(function() {
$("#table1").dataTable({
"preocessing" : true,
"serverSide" : true,
"sAjaxSource" : "dtable2.php",
"columns" : [
{"data" : "aaData.1"},
{"data" : "aaData.3"},
{"data" : "aaData.4"},
{"data" : "aaData.5"},
{"data" : "aaData.2"},
]
});
});
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
</head>
<body>
<table id="table1">
<thead>
<tr>
<th>Id</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Date</th>
</tr>
</thead>
</table>
</body>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
</html>
但我在结果中收到了警告
“DataTables warning(table id ='table1'):请求的未知参数 第0行“
的数据源为”0“
我的问题与建议的问题无关。
答案 0 :(得分:2)
您尝试此代码:
<script type="text/javascript">
$(document).ready(function() {
$("#table1").dataTable({
"preocessing" : true,
"serverSide" : true,
"sAjaxSource" : "dtable2.php",
"columns" : [
{"data" : "id"},
{"data" : "fname"},
{"data" : "lname"},
{"data" : "email"},
{"data" : "reg_d"},
]
});
});
查看更多:Columns render
答案 1 :(得分:0)
您不是在这里将正确的数据形式与插件相加,
"columns" : [
{"data" : "aaData.1"},
{"data" : "aaData.3"},
{"data" : "aaData.4"},
{"data" : "aaData.5"},
{"data" : "aaData.2"},
]
例如:插件无法读取aaData.1
。