2012-08-09 90 views
1

我正在使用jQuery Cookie Plugin,並且它在所有頁面上的運行都很好,除了在主頁上運行該頁面外,我正在敲打我的頭,但沒有運氣。爲什麼jQuery Cookie Plugin不能在特定頁面上工作?

我的代碼如下所示:

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

在Firebug它說:

遺漏的類型錯誤:對象功能(A,B){返回新e.fn.init(A,B,H) }有沒有方法'餅乾'

有人可以請指導什麼是這個錯誤,以及如何刪除它?

回答

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兩次?

解決方案:

刪除谷歌裝載機,並要求它從你家頁面的頁腳加載jQuery的。

0

您確定插件已加載到您的主頁上嗎?你看過源頭嗎? 你也可以檢查你的firebug中的加載腳本。

+0

是的,我檢查和插件加載在我的主頁上,你可以看到自己... http://www.unicaimmobili.com/index_copy – user1433900 2012-08-09 11:37:12

相關問題