类型错误:$(...)数据表是不是一个函数。 [英] TypeError: $(...).DataTable is not a function

查看:362
本文介绍了类型错误:$(...)数据表是不是一个函数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从链接。

我从同一源下载的完整文库。在包中给出的所有例子似乎很好地工作,但是当我试图将其纳入我的的WebForms 中,CSS,JS不要在所有的工作。

I downloaded the complete library from the same source. All the examples given in the package seem to work fine, but when I try to incorporate them in my WebForms,the CSS,JS do not work at all.

下面是我做了什么:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="myTable" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
            <tbody>
               <!-- table body -->
            </tbody>
        </table>
    </div>
    <script src="js/jquery.dataTables.js" type="text/javascript"></script>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#myTable').DataTable();
        });
    </script>
    </form>
</body>
</html>

我对JS文件结构和CSS在我的解决方案如下所示:

My file structure for the JS and CSS in my Solution looks as follows :

我添加了所有必要的JS和CSS参考如图所示说明书中无。仍然并不如预期的渲染。没有CSS和甚至JS的不工作

I have added all the necessary JS and CSS references as shown in the manual. Still the rendering isn't as expected. There is no CSS and even the JS doesn't work.

此外,在控制台中我得到以下错误:

Also in the console i get the following errors:

ReferenceError: jQuery is not defined
TypeError: $(...).DataTable is not a function

我仍然没有束缚这里的任何动态数据(如中继器内或左右)仍是不工作的。

I have still not bound any dynamic data here (like within a repeater or so) still it is not working.

有人能指导我这个问题的正确方向?

Can someone please guide me in the right direction for this problem ?

推荐答案

您需要之前的加载的jQuery的您加载任何jQuery的相关code,如jQuery的数据表,见下图:

You need to load jQuery before you load any jQuery-related code such as jQuery DataTables, see below:

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.dataTables.js" type="text/javascript"></script>

此外,对于量产版则建议加载缩小的版本(与 .min.js 结束,而不是)。

这篇关于类型错误:$(...)数据表是不是一个函数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆