1

我正在使用 jQuery Cookie 插件,它在除主页之外的所有页面上都可以正常工作,以运行该页面我正在敲我的头,但没有运气。

我的代码如下所示:

$.cookie('CA_txtKeywords', $("#CAT_txtKeywords").val(), { expires: 7, path: '/' });

在萤火虫它说:

未捕获的类型错误:对象函数 (a,b){return new e.fn.init(a,b,h)} 没有方法 'cookie'

有人可以指导这个错误是什么以及如何删除它?

4

2 回答 2

7

您在脑海中包含 jQuery,然后包含 cookie 插件,但在页面底部您会看到:

        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">
  // You may specify partial version numbers, such as "1" or "1.3",  with the same result. Doing so will automatically load the latest version matching that partial revision pattern 
  // (e.g. 1.3 would load 1.3.2 today and 1 would load 1.4.1).
  google.load("jquery", "1");

  google.setOnLoadCallback(function() {
    // Place init code here instead of $(document).ready()
$(".euro").parseNumber({format:"#,###", locale:"it"});
$(".euro").formatNumber({format:"#,###", locale:"it"});

})
</script>

它使用谷歌加载器再次加载 jQuery。因为您再次加载 jQuery,所以直接附加到文档头部的 jQuery 命名空间(而不是原型)的任何内容都会被删除。

所以归根结底,你到底为什么要加载 jQuery 两次?

解决方案:

删除 google 加载器并请求它从主页的页脚加载 jQuery。

于 2012-08-09T11:47:36.100 回答
0

您确定插件已加载到您的主页上吗?你查过源头吗?你也可以在你的萤火虫中检查加载的脚本。

于 2012-08-09T11:34:14.767 回答