Mcload
Mcload

Reputation: 308

jQuery works on my page, but firebug says $ is not defined error. Why and how to avoid it?

UPDATE: Finally I found the solution, it was totally my fake. There were an iframe tag on the site, and in the external file I didn't include jQuery. But I learned a lot from your answer and checked my code a lot of time. :) update END.

Firebug console issues the following error message: $ is not defined ajaxlib.js()ajaxlib.js (line 6) [break on this error] $(document).ready(function()

But jQuery works perfectly on my page. I include the jQuery source in the first script tag (it was the most commonly suggested solution), so it's should be loaded.

Any help appreciated.

<script language="javascript" type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script language="javascript" type="text/javascript" src="js/advexpad_lib.js"></script>
<script language="javascript" type="text/javascript" src="js/ajaxlib.js"></script>
<script language="javascript" type="text/javascript" src="js/highlight.pack.js"></script>

Upvotes: 2

Views: 2514

Answers (2)

hivie7510
hivie7510

Reputation: 1246

Based on the error, the problem is in the 3rd script. Try moving the second script below the 3rd one. The advexpad maybe overwriting the $ shortcut in their module. Also including jquery first isn't recommended, but rather required in your case. Since the 3rd script uses it, you have to have it precede it.

Upvotes: 0

Arda
Arda

Reputation: 6916

Try changing all $ characters with "jQuery". They are possibly conflicting with an other library you are including.

as in;

$(document).ready(function() {} );

to

jQuery(document).ready(function() {} );

Upvotes: 2

Related Questions