Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "jQuery is not defined", but jquery is loaded

Tags:

jquery

but trying to operate jquery validate plugin 1.6 but im getting this error in Chrome inspector:

Uncaught ReferenceError: jQuery is not defined. ------ jquery.validate.min.js:15

I'm loading jquery 1.4.4 in my page.

Any idea?

Regards

Javi

like image 894
ziiweb Avatar asked Dec 29 '22 04:12

ziiweb


2 Answers

You need to make sure jquery is loaded first, before the validation plugin.

like image 156
Pekka Avatar answered Jan 11 '23 02:01

Pekka


Ensure that you're not importing jQuery more than once! In my case, I began my .cshtml view in asp.net with

<script src="~/Scripts/jquery.js"></script>

and then at the end of my code, I forgot that I left this behind:

@Scripts.Render("~/bundles/jqueryval")

Importing jQuery more than once on a page can cause no end of issues. See this bug report from the jQuery project for more information, but this quote stood out to me:

[If you have jQuery referenced more than once on a page]...As jQuery script executes it re-initializes $ and $.prototype, which removes all existing plug-ins. The host page stops working.

like image 28
FoxDeploy Avatar answered Jan 11 '23 03:01

FoxDeploy