TypeError DataTable is not a function

0 votes

I am working on jQuery's Datatable JS for my project and I downloaded the complete library. But when I tried to incorporate them in WebForms, the CSS, and JS do not work at all.

Here is what I have done till now :

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

I have done everything as in the manual but still, the rendering isn't as expected. and in the console I get the following errors:

ReferenceError: jQuery is not defined

TypeError: $(...).DataTable is not a function

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

Apr 29, 2022 in Git & GitHub by Kichu
• 19,040 points
14,009 views

1 answer to this question.

0 votes

This happened because the jQuery DataTables library is missing or the jQuery library is loaded after jQuery DataTables. This can be solved by including only one version of the jQuery library version 1.7 or newer.

For example:

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

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

For more info:  jQuery DataTables: Common JavaScript console errors.

I hope this helps.

answered Apr 30, 2022 by narikkadan
• 63,600 points

Related Questions In Git & GitHub

0 votes
1 answer

How to forcefully commit a file to Git even if the file is ruled as unchanged?

This is simple, just follow the below ...READ MORE

answered Jul 11, 2018 in Git & GitHub by Sophie may
• 10,620 points
14,106 views
0 votes
1 answer
0 votes
1 answer

Is there a way to remove a directory from git repository?

This is simple, just follow the commands ...READ MORE

answered Jul 14, 2018 in Git & GitHub by Sophie may
• 10,620 points
1,234 views
0 votes
1 answer

How do I solve a Git checkout error: updating paths is incompatible with switching branches?

This error occurs when you are checking ...READ MORE

answered Jul 26, 2018 in Git & GitHub by Sophie may
• 10,620 points
10,522 views
+2 votes
5 answers

ERROR: 'git' is not recognized as an internal or external command.

You have to set your PATH to ...READ MORE

answered Aug 2, 2018 in Git & GitHub by Sophie may
• 10,620 points
47,411 views
0 votes
1 answer

Why is Git commit not functioning with Git Bash?

This occurs because you might have git ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Sophie may
• 10,620 points
3,968 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

I struggled with a similar problem for ...READ MORE

answered Feb 17, 2022 in Java by Soham
• 9,710 points
6,388 views
0 votes
1 answer

jQuery UI " $("#datepicker").datepicker is not a function"

The "$(...).datepicker is not a function" jQuery ...READ MORE

answered Jun 6, 2022 in JQuery by Edureka
• 13,690 points
15,256 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,314 views
0 votes
1 answer

Uncaught TypeError: Cannot read property 'msie' of undefined - jQuery tools

Hello, Use the following script tag in your ...READ MORE

answered Apr 28, 2020 in JQuery by Niroj
• 82,840 points
15,709 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP