开发者

jQuery cookie plugin - $cookies is not defined

I have searched around an开发者_运维知识库d no other solution fits my problem.

I am using the jQuery cookie plugin to implement a show/hide section on my site.

When testing the site locally (using WAMP) my jQuery code shows no errors, yet once it's uploaded to my site, an error saying:

$.cookie is not a function

I have tried many different solutions so am thinking it might be something with the server my website is uploading to...

Any help is appreciated

$.cookie("slider", "hidden");
alert($.cookie("slider"));

www.visio-design.co.uk/dpgd/index.php


cheers for the quick responses. i changed the name of the file from "jquery.cookie.js" to jquery.cooki.js" and its working fine.

would be great if anybody could give me an insight into why this is happening? i've read that it maybe something to do with my htaccess file?


I have opened the site using firebug and there is a 404 error for the jquery.cookie.js. Make sure you copied the jquery.cookie.js file to the same path where the jquery-1.4.4.js and other js files exist.


Double check that your jquery.cookie.js file is loaded on the server where you think it is. When I try to view it, I get a 404 error. It also mentions a 406 error, which is pretty unusual.


You're getting a 406 error on loading your cookie.js file. Make sure it's in the right place with the right permissions.

Edit to add:

The 406 error was viewed from within firebug checking out the contents of the script.


Contacting my web provider and having them disable the mod_security rule fixed this issue for me. This rule blocks files with .cookie in the name.

I tried several other fixes that can also work depending on your access level and configuration:

  1. In cPanel use the ModSec manager to disable the setting: This sometimes fails to affect sub-domains so did not work for me.
  2. Disabling the rule in the .htaccess file following the instructions at http://www.liewcf.com/how-to-disable-mod_security-in-htaccess-file-3631/ : This failed to work for me I believe because of the override policies in place with my host.
  3. Adding:

    <IfModule mod_security2.c>
    SecRuleEngine Off
    </IfModule>
    

    to the VirtualHost entry of the domain in the Apache configuration file : Unfortunately I did not have access to override settings in the Apache configuration.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜