jQuery cookie 插件 - $cookies 未定义

发布于 2024-10-14 01:27:19 字数 468 浏览 6 评论 0原文

我四处搜寻,没有其他解决方案适合我的问题。

我正在使用 jQuery cookie 插件在我的网站上实现显示/隐藏部分。

在本地测试网站时(使用 WAMP),我的 jQuery 代码没有显示任何错误,但一旦将其上传到我的网站,就会出现错误:

$.cookie is not a function

我尝试了许多不同的解决方案,所以我认为这可能与我的网站上传到的服务器有关。 ..

任何帮助表示赞赏

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

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

I have searched around and 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

轻许诺言 2024-10-21 01:27:19

联系我的网络提供商并让他们禁用 mod_security 规则为我解决了这个问题。此规则会阻止名称中带有 .cookie 的文件。

我尝试了其他几个修复程序,这些修复程序也可以根据您的访问级别和配置起作用:

  1. 在 cPanel 中使用 ModSec 管理器禁用该设置:这有时无法影响子域,因此对我不起作用。
  2. 按照 中的说明禁用 .htaccess 文件中的规则http://www.liewcf.com/how-to-disable-mod_security-in-htaccess-file-3631/:这对我不起作用,我相信是因为我的主机实施了覆盖策略。
  3. 添加:

    ;
    SecRuleEngine 关闭
    
    

    到 Apache 配置文件中域的 VirtualHost 条目:不幸的是,我无权覆盖 Apache 配置中的设置。

希望这有帮助!

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!

老子叫无熙 2024-10-21 01:27:19

仔细检查您的 jquery.cookie.js 文件是否已加载到您认为所在的服务器上。当我尝试查看它时,出现 404 错误。它还提到了 406 错误,这是非常不寻常的。

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.

太傻旳人生 2024-10-21 01:27:19

您在加载 cookie.js 文件时遇到 406 错误。确保它位于正确的位置并具有正确的权限。

编辑添加:

406错误是从firebug中查看脚本内容来查看的。

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.

终难遇 2024-10-21 01:27:19

为快速反应欢呼。我将文件名从“jquery.cookie.js”更改为 jquery.cooki.js“,它工作正常。

如果有人能让我深入了解为什么会发生这种情况,那就太好了?我读过,可能是这样与我的 htaccess 文件有关吗?

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?

不寐倦长更 2024-10-21 01:27:19

我已经使用 firebug 打开了该网站,并且 jquery.cookie.js 出现 404 错误。
确保将 jquery.cookie.js 文件复制到 jquery-1.4.4.js 和其他 js 文件所在的同一路径。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文