jQuery cookie 插件 - $cookies 未定义
我四处搜寻,没有其他解决方案适合我的问题。
我正在使用 jQuery cookie 插件在我的网站上实现显示/隐藏部分。
在本地测试网站时(使用 WAMP),我的 jQuery 代码没有显示任何错误,但一旦将其上传到我的网站,就会出现错误:
$.cookie is not a function
我尝试了许多不同的解决方案,所以我认为这可能与我的网站上传到的服务器有关。 ..
任何帮助表示赞赏
$.cookie("slider", "hidden");
alert($.cookie("slider"));
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"));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
联系我的网络提供商并让他们禁用 mod_security 规则为我解决了这个问题。此规则会阻止名称中带有 .cookie 的文件。
我尝试了其他几个修复程序,这些修复程序也可以根据您的访问级别和配置起作用:
添加:
到 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:
Adding:
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!
仔细检查您的 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.
您在加载
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.
为快速反应欢呼。我将文件名从“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?
我已经使用 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.