[英]Why is Firebug saying that $.cookie() is not a function?
I am trying to set a cookie with jQuery 1.7.1: 我正在尝试使用jQuery 1.7.1设置Cookie:
var global_namesArray = ["Alex", "Bob", "Carmen"];
$.cookie("namesArray", global_namesArray);
I retrieve this cookie like this: 我像这样检索此cookie:
if ($.cookie("namesArray") != null)
global_namesArray = $.cookie("namesArray");
However, the page's javascript does not load. 但是,该页面的javascript无法加载。 When I use Firebug to analyze my page, the console reads that $.cookie() is not a function.
当我使用Firebug分析页面时,控制台会读取$ .cookie()不是函数。 The error occurs during cookie retrieval I believe.
我相信在Cookie检索期间会发生错误。 I am sure that I have linked jQuery.
我确定我已经链接了jQuery。
Am I using the jQuery $.cookie() function correctly? 我是否正确使用jQuery $ .cookie()函数?
.cookie is not a native function for jQuery. .cookie不是jQuery的本机功能。 Do you have the cookie plugin installed?
您是否已安装Cookie插件 ?
Edit: I just tested, and I get this error if I include jQuery but not the cookie plugin: 编辑:我刚刚测试过,如果我包含jQuery但不包含Cookie插件,则会出现此错误:
"$.cookie is not a function".
You probably just need to add the cookie plugin. 您可能只需要添加cookie插件。
确保jquery.cookie.js
之后包括jquery.js
,那你是不是其中jquery.js
不止一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.