我没有问题,我喜欢它是在建议的问题。如何使用ajax在数据表中显示这些数据?
{
"aaData": [
{
"id": "1",
"reg_d": "2017-09-15 10:15:57",
"fname": "Vishwas",
"lname": "Jadav",
"email": "[email protected]"
},
{
"id": "50",
"reg_d": "2017-09-20 14:33:59",
"fname": "testA",
"lname": "testk",
"email": "[email protected]"
},
{
"id": "51",
"reg_d": "2017-09-20 14:36:18",
"fname": "mvjh",
"lname": "kgjk",
"email": "[email protected]"
}
],
"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>
,但我得到一个警告的结果
“的DataTable警告(表ID =“表1 '):从行0的数据源请求未知参数 '0'
我没有问题,我喜欢它是在建议的问题。
[数据表的警告可能重复:从数据源请求的未知参数 '0'行'0'](https://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row) –
@DarrenSweeney我尝试了最新版本,但仍然是一样的警告。 –