为什么Firebug说$ .cookie()不是一个函数? [英] Why is Firebug saying that $.cookie() is not a function?

查看:242
本文介绍了为什么Firebug说$ .cookie()不是一个函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用jQuery 1.7.1设置Cookie:

I am trying to set a cookie with jQuery 1.7.1:

var global_namesArray = ["Alex", "Bob", "Carmen"];
$.cookie("namesArray", global_namesArray);

我检索这个cookie:

I retrieve this cookie like this:

if ($.cookie("namesArray") != null)
    global_namesArray = $.cookie("namesArray");

但是,不会加载页面的javascript。当我使用Firebug来分析我的页面时,控制台读取$ .cookie()不是一个函数。我相信cookie检索期间发生错误。我确信我已经链接jQuery。

However, the page's javascript does not load. When I use Firebug to analyze my page, the console reads that $.cookie() is not a function. The error occurs during cookie retrieval I believe. I am sure that I have linked jQuery.

我是否正确使用jQuery $ .cookie()函数?

Am I using the jQuery $.cookie() function correctly?

推荐答案

.cookie不是jQuery的本地函数。是否安装了 Cookie插件

.cookie is not a native function for jQuery. Do you have the cookie plugin installed?

编辑:
我刚刚测试,我得到这个错误,如果我包括jQuery,而不是cookie插件:

I just tested, and I get this error if I include jQuery but not the cookie plugin:

"$.cookie is not a function".

您可能只需要添加cookie插件。

You probably just need to add the cookie plugin.

这篇关于为什么Firebug说$ .cookie()不是一个函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆