我使用了jQuery插件的cookie(也試圖與EZCookie),我堅持這個錯誤在Firefox:
'$.cookie is not a function'
at line:
if(!($.cookie('name') == null)) {
我得到不同的JavaScript錯誤在IE 6
"Object doesn't support this property or method"
奇怪的是,當我評論$(document).ready(function() {
,
我沒有得到任何錯誤,但後來我也沒有看到該Cookie(即使設置後曲奇餅從另一個應用程序)。
任何人有一個線索什麼怎麼回事....
下面是代碼我使用:
<script type="text/javascript">
var var2= "";
$(document).ready(function() {
if($.cookie('name').length > 0) {
alert("cookie present"+$.cookie('name'));
<%
String[] var1= (String[]) componentRequest.getComponentSession().getValue("var");
if(!(null == offices)){
for(int i = 0; i < var1.length; i++){%>
var2+=<%=var1[i]%>+",";
<%}
}%>
$('#tempCookieVal').val(var2+$.cookie('name'));
$('#cookieForm').submit();
}else{
alert("no cookie");
$('#tempCookieVal').val("NoCookie");
$('#cookieForm').submit();
}
alert("cookie check done");
});
</script>
<form id="cookieForm" >
<input name="tempCookie" type="hidden" id="tempCookieVal" />
</form>
發佈一些源代碼? – razzed 2011-03-08 19:52:06
查看答案米哈伊爾,如果這沒有幫助,看看你是否可以重現我們可以看到它的地方(http://jsfiddle.net會很好) – JAAulde 2011-03-08 19:53:29
我更新了代碼,我只使用一次包括jquery .js文件。 – jqueryEnthusiast 2011-03-08 20:23:40