开发者

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(开发者_如何学C)

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>


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() {} );


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜