views:

40

answers:

3

I have a javacript code coupon.js defined as follows -

jQuery(document).ready(function(){
jQuery('.appnitro').submit( function() {
$.ajax({
 url : $(this).attr('action'),
 type : $(this).attr('method'),
 dataType: 'json',
 data : $(this).serialize(),
 success : function( data ) {
 for(var id in data) {
 jQuery('#' + id).html( data[id] );
 }
 }
 });

Now firebug throws following error -

jQuery is not defined
[Break on this error] jQuery(document).ready(function(){\n

Can someone explain me the error and ways to remove it.Thanks in advance

+3  A: 

It looks like your page doesn't include jquery

<script type="text/javascript"
   src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;
</script>
BioBuckyBall
+5  A: 

Put this into the head section of your page before any other script:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
Darin Dimitrov
It doesn't need to be in the <head>. Many JS Guru's are advocating putting these at the end of the Body to speed up the page load.
Ryan Ternier
A: 

How are you referencing your JQuery JS script files? Either they're pointing to a location that doesn't exist, they don't exist, or you used a self-closing script tag ()

Ryan Ternier