WordPress Uncaught ReferenceError: jQuery is not defined

WordPress Uncaught ReferenceError: jQuery is not defined

cblackcblack Posts: 5Questions: 3Answers: 0

Link to test case: https://gceatemp.wpenginepowered.com/test-member-directory/
Debugger code (debug.datatables.net):
Error messages shown: Uncaught ReferenceError: jQuery is not defined
Description of problem:

I had used data tables before and similar code had worked. I am not sure why I can't get this functoning.
I fill in a member table with values manually.

jQuery(document).ready( function () { jQuery('#all-users').DataTable( {"responsive": true, "paging": false, "info": false, "searching": true } ); } );

in the php code -

echo '

'; foreach( $all as $one ) { $status = "No"; $membership = ""; $corporate = "No"; echo ''; } echo '
NameMember?  Membership  Primary?&nbsp Program
' . $one->first_name . '' . $status . '' . $membership . '' . $corporate . '' . "private" . '

';

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017

    You are getting the error here in line 2:

    This is the first thing executed in your script before any of the Javascript library includes.

    I don't see where you are loading jquery.js on the page. You have this:

    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.10.18/b-1.5.2/b-html5-1.5.2/b-print-1.5.2/r-2.2.2/datatables.min.js">
    

    You will want to load jquery.js before this as datatables requires jQuery. You will also want to move the script block you have at the top after you load jquery.js since it relies on jquery.js being loaded.

    Kevin

  • kthorngrenkthorngren Posts: 21,670Questions: 26Answers: 5,017
    edited February 13 Answer ✓

    I'm not familiar with Wordpress but, after doign a bit of research, it sounds like WP comes "pre-loaded" with jQuery. You are getting the error before trying to load Datatabes. The error might be something specific with the WP environment/config. Maybe this tutorial will help with using Javascript libraries with Wordpress. Or possibly review the Wordpress docs for using jQuery.

    Kevin

  • cblackcblack Posts: 5Questions: 3Answers: 0

    Thanks for taking the time to debug this and respond. It is tough getting this to work in WordPress. There are a couple WordPress plugins that include data tables, like TablePress and wpDataTables. I'm working on using them instead.

Sign In or Register to comment.