数据表插件返回错误

发布于 2024-12-22 11:16:21 字数 1016 浏览 0 评论 0原文

我正在使用数据表插件从服务器端获取数据。 我尝试过更改 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲性难收 2024-12-29 11:16:21

尝试数据表论坛中建议的解决方案

错误原因:无效标签

另一件事:

正如数据表的作者所说:

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.
"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文