数据表插件返回错误
我正在使用数据表插件从服务器端获取数据。 我尝试过更改 JQuery 的版本甚至选项,但仍然无法解决该错误。这是我的 HTML 代码
<html>
<head>
<script type = "text/javascript" src = "jquery.min.js"></script>
<script type = "text/javascript" src = "DataTables-1.8.2/media/js/jquery.dataTables.min.js"></script>
<script type = "text/javascript">
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
"bFilter": true,
"bPaginate " : true,
"bServerSide" : true,
"sAjaxSource": "data.php"
});
});
</script>
</head>
<body>
</body>
</html>
,我的服务器端正在返回以下形式的数组:
{
"sEcho":0,
"iTotalRecords":"6",
"iTotalDisplayRecords":"6",
"aaData":[
["5","admin","5"],
["1","user","0"],
["2","user1","1"],
["4","user2","2"],
["3","user3","3"],
["6","user4","4"]]
}
这是网站上所需的格式。 Firebug显示上面的JSon并且有错误无效标签。
有人可以指出数据表实现中可能存在的错误吗?
I am using Datatables plugin to get data from server side.
I have tried changing the versions of JQuery and even the options, but still not able to resolve the error. This is my HTML code
<html>
<head>
<script type = "text/javascript" src = "jquery.min.js"></script>
<script type = "text/javascript" src = "DataTables-1.8.2/media/js/jquery.dataTables.min.js"></script>
<script type = "text/javascript">
$(document).ready(function() {
$('#example').dataTable({
"bJQueryUI": true,
"bFilter": true,
"bPaginate " : true,
"bServerSide" : true,
"sAjaxSource": "data.php"
});
});
</script>
</head>
<body>
</body>
</html>
And my server side is returning an array of the form
{
"sEcho":0,
"iTotalRecords":"6",
"iTotalDisplayRecords":"6",
"aaData":[
["5","admin","5"],
["1","user","0"],
["2","user1","1"],
["4","user2","2"],
["3","user3","3"],
["6","user4","4"]]
}
This is the desired format on the site. The Firebug displays the above JSon and there is an error invalid label.
Can somebody point out the possible error in Data Tables implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试数据表论坛中建议的解决方案
错误原因:无效标签
另一件事:
正如数据表的作者所说:
”
sEcho 永远不应该是“0”。它应该是 DataTables 发送到服务器的值的回显。
”
try the suggested solution from the datatables forum
Reasons for error: invalid label
another thing :
As said the author of datatables:
"
sEcho should never be '0'. It should be an echo of the value that is sent to the server by DataTables.
"