Uncaught ReferenceError: jQuery is not defined at jquery.dataTables.js:56

Uncaught ReferenceError: jQuery is not defined at jquery.dataTables.js:56

gib65gib65 Posts: 29Questions: 13Answers: 0

Hello,

When I include the references for DataTable:

<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.13/js/jquery.dataTables.js"></script>

I get an error in the Chrome console:

Uncaught referenceError: jQuery is not defined, at line 56 of jquery.dataTables.js

Line 56 in jquery.dataTables.js is:

factory( jQuery, window, document );

This error doesn't come up if I remove the references.

Is this a known bug? Is there a way to fix it? Does it have anything to do with jquery.dataTables.js clashing with something in my application?

Thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,368Questions: 26Answers: 4,956

    The problem is that jQuery is not loaded:
    https://datatables.net/manual/installation#Dependencies

    Kevin

  • gib65gib65 Posts: 29Questions: 13Answers: 0

    But I do have JQuery loaded.

    If I say $("#JQuery_DataTable").length, it gives me 1.

    Could it be that it doesn't recognize the instance of JQuery I'm using?

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited March 2017

    But I do have JQuery loaded.

    It's not visible in the code you posted. Show us the relevant code.

    EDIT: I've just seen your other post. So do you have DataTables working or not?

  • gib65gib65 Posts: 29Questions: 13Answers: 0

    I have data tables working. I'm just not sure if this error is preventing full functionality or not.

    I'm currently trying to find where we reference JQuery in our application. I'll have to get back to you on that.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    If you have a link to the page you are working on we can take a look.

    Allan

  • gib65gib65 Posts: 29Questions: 13Answers: 0

    It turns out the errors go away when I bring the references over to the page with the DataTable as opposed to the master page shared by the whole application.

    There must have been some conflict between the JQuery we're using and the JQuery required by the DataTable.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    DataTables works with jQuery 1.7 and newer.

    You should load jQuery only once per page. It sounds like you might be trying to load it twice on the page.

    Allan

  • udaykiran87udaykiran87 Posts: 3Questions: 1Answers: 0

    I am using latest jquery version, but getting error with DataTables js file.

    jQueryDataTables/js/jquery.dataTables.js:40 Uncaught ReferenceError: jQuery is not defined
    at _re_dic (jQueryDataTables/js/jquery.dataTables.js:40)
    at /jQueryDataTables/js/jquery.dataTables.js:46
    at /jQueryDataTables/js/jquery.dataTables.js:14381.

    I am using DataTables js in VF page.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin

    @udaykiran87 - Please don't post duplicates. The forum rules are really basic. Please follow them.

    Allan

  • rahulshawrahulshaw Posts: 1Questions: 0Answers: 0

    The issue here I am guessing is the order between loading the jQuery library and the datatables library. In the page, define <script> tag for jquery first and datatables thereafter.

This discussion has been closed.