0

我刚刚开始使用 jquery 数据表进行开发。我想从(Grails)服务器返回的数据中填充表。目前,从不调用服务器方法。我的页面如下所示:

<html>
<head>
    <script src="/attendance/static/plugins/jquery-1.8.3/js/jquery/jquery-1.8.3.min.js" type="text/javascript" ></script>
    <link href="http://code.jquery.com/ui/1.10.3/themes/trontastic/jquery-ui.css" type="text/css" rel="stylesheet" media="screen, projection" />
    <script src="/attendance/static/plugins/jquery-ui-1.8.24/jquery-ui/js/jquery-ui-1.8.24.custom.min.js" type="text/javascript" ></script>
<script src="/attendance/static/js/jquery.dataTables.js"
    type="text/javascript"></script>

<script>
    $(document).ready(function() {
        $('#example').dataTable({
            "bServerSide" : true,
            "sAjaxSource" : "/events/index"
        });
    });
</script>
</head>
<body>
    <table id="example">
        <thead />
        <tbody />
    </table>

</body>
</html>

服务器日志中没有任何条目表明曾经调用过 sAjaxSource 指定的方法。如果我在浏览器中手动查询 /events/index,则会调用该方法(并返回有效的 JSON),并且此请求在服务器日志中可见。

在调用 dataTable 之前放置的警报正常工作。我使用了 Firebug 并验证了 dataTable 调用确实发生了——尽管在那之后它显然会深入到 dataTables 代码中,而且我绝不是 Javascript 专家。

我是否犯了一个非常明显的错误?

4

1 回答 1

-1

Jquery.dataTables - 这是一个 jquery 插件。

但是在您的示例中,没有包含 jquery 库。

可能是个问题?

于 2013-11-10T22:22:38.960 回答