Uncaught ReferenceError: jQuery is not defined

user2541351 picture user2541351 · Jul 2, 2013 · Viewed 37.1k times · Source

I'm trying to put together a Wordpress site with a JQuery slider plugin, but the plugin doesn't display on the page and I always get the above error message.

Despite trying several different fixes suggested in other's posts I still can't seem to fix the above error, including putting the script tag in the 'header.php' file. Any help would be much appreciated - thanks!

Relevant code in 'footer.php' file

    <!--Load JQuery-->  
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>


</body> 
</html>

The Website:http://www.advanceprojects.com.au/

Answer

Sushanth -- picture Sushanth -- · Jul 2, 2013

Scripts always run in a sequential order.

So basically you are trying to use jQuery even before the jQuery library is loaded.

Your script is dependent on Nivo which in turn depends on jQuery library.

Either move the script to the line after the library is loaded, or move the library declaration to the head.

Also make sure you enclose the script inside DOM Ready handler.

So the order in which you should be loading these are

-- jQuery 
  -- Nivo Slider
  -- your script that uses the above 2 libraries.