• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 190


File: /var/www/html/thecodehelp.com/application/views/question.php
Line: 190
Function: _error_handler

File: /var/www/html/thecodehelp.com/application/controllers/Questions.php
Line: 416
Function: view

File: /var/www/html/thecodehelp.com/index.php
Line: 315
Function: require_once

I have a simple jQuery script in a WordPress plugin that is using a jQuery wrapper like this:


    // jQuery code is in here


I am calling this script from within the WordPress Dashboard and am loading it AFTER the jQuery framework has loaded.

When I check the page in Firebug I constantly keep receiving the error message:

TypeError: $ is not a function


Should I maybe wrap the script in this function:


    // jQuery code is in here


I have had this error quite a few times and am not sure how to handle it.

Any help would be greatly appreciated.

By default when you enqueue jQuery in Wordpress you must use jQuery, and $ is not used (this is for compatibility with other libraries).

Your solution of wrapping it in function will work fine, or you can load jQuery some other way (but that's probably not a good idea in Wordpress).

If you must use document.ready, you can actually pass $ into the function call:

jQuery(function ($) { ...
  • 0
Reply Report