Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to fix 'jQuery is not defined' error in jquery library?

Rails fix: make sure <%= javascript_include_tag "application" %> is before any script loading so that jquery gets loaded first.

This seems really odd. When I load my page I get 2 js errors (in Chrome):

jquery-ui.min.js:17  Uncaught ReferenceError: jQuery is not defined
jquery.blockUI.js:499  Uncaught ReferenceError: jQuery is not defined

Ok, that seems... odd. So I look at my script includes. My first two script includes on my page:

 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
  <script src="http://bainternet-js-cdn.googlecode.com/svn/trunk/js/jQuery%20BlockUI%20Plugin/2.39/jquery.blockUI.js"></script>

So the first include is getting a javascript error related to itself? That seems unlikely. This looks like a case of a misdirection error (the real error is somewhere else). What can I do to fix this? JS errors on pages look a little unprofessional (at least to other devs). I wasn't getting this error the other day -- even reverted the code to make sure.

like image 366
jcollum Avatar asked Feb 13 '12 19:02

jcollum


1 Answers

your

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

needs to be called before jquery ui < script > tags.

Should appear like this:

 <script type="text/javascript" src="jquery.js"></script> <-- put me here -->
 <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
 <script src="http://bainternet-js-cdn.googlecode.com/svn/trunk/js/jQuery%20BlockUI%20Plugin/2.39/jquery.blockUI.js"></script>
like image 178
Downpour046 Avatar answered Nov 15 '22 20:11

Downpour046