开发者

jquery.cookie plugin, gettign an error saying jquery is not defined?

开发者 https://www.devze.com 2022-12-09 18:22 出处:网络
I included the jquery.cookie.js in my application and I am getting a firefox error saying jquery is not defined?

I included the jquery.cookie.js in my application and I am getting a firefox error saying jquery is not defined?

I have jquery in the project FOR SURE, removing the jquery.cookie.js 开发者_开发问答script gets rid of the error.

What could be the reason for this?


Make sure you have jQuery declared before jQuery.cookie.js

You can't use the jQuery object until it's declared and thus why it does matter the order.


if you are using mulitple versions of jquery in one script you might get that error. solution

Using different versions of jQuery and jQueryUI together


To make sure jQuery is available wrap your jQuery code in:

(function ($) {
     // your Code.
})(jQuery);

Additionally you may check for jquery.cookie:

(function ($) {
    if (typeof $.cookie != 'undefined'){
        var test = ($.cookie('test') === 'true');
    }
})(jQuery);
0

精彩评论

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