admin管理员组文章数量:1296873
I am using the jQuery cookie plugin (also tried with EZCookie), I am stuck with this error in firefox:
'$.cookie is not a function'
at line:
if(!( $.cookie('name') == null) ) {
I get a different javascript error in IE 6
"Object doesn't support this property or method"
Strange thing is when I mented $(document).ready(function() {
,
I don't get any error, but then I also don't see the cookie (even after setting the cookie from another application).
Anybody has a clue whats going on here....
Here is the code am using:
<script type="text/javascript">
var var2= "";
$(document).ready(function() {
if($.cookie('name').length > 0) {
alert("cookie present"+$.cookie('name'));
<%
String[] var1= (String[]) ponentRequest.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>
I am using the jQuery cookie plugin (also tried with EZCookie), I am stuck with this error in firefox:
'$.cookie is not a function'
at line:
if(!( $.cookie('name') == null) ) {
I get a different javascript error in IE 6
"Object doesn't support this property or method"
Strange thing is when I mented $(document).ready(function() {
,
I don't get any error, but then I also don't see the cookie (even after setting the cookie from another application).
Anybody has a clue whats going on here....
Here is the code am using:
<script type="text/javascript">
var var2= "";
$(document).ready(function() {
if($.cookie('name').length > 0) {
alert("cookie present"+$.cookie('name'));
<%
String[] var1= (String[]) ponentRequest.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>
Share
Improve this question
edited Mar 8, 2011 at 20:22
jqueryEnthusiast
asked Mar 8, 2011 at 19:47
jqueryEnthusiastjqueryEnthusiast
1551 gold badge7 silver badges17 bronze badges
4
- See answer by Mikhail and if that doesn't help, see if you can reproduce somewhere that we can see it ( jsfiddle would be great) – JAAulde Commented Mar 8, 2011 at 19:53
- I updated with code, I am using only once include of jquery.js. – jqueryEnthusiast Commented Mar 8, 2011 at 20:23
- Then what you've posted so far is not enough. We really need to see all this in context, running live even. – JAAulde Commented Mar 8, 2011 at 22:43
- You can post a link to your website - we'll view the source ;) – Mikhail Commented Mar 9, 2011 at 15:13
2 Answers
Reset to default 9Check to make sure you don't include jquery.js
twice. Including it the second time will destroy whatever addons you have added.
Same goes for including any javascript that overwrites $
Example:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/js/jquery.js"></script>
This will act as if you've never included cookie
Did you include the cookie plugin ? If yes, is it after the jquery.js include ?
本文标签: javascriptquotcookie is not a functionquot error in FF eventhough I include itStack Overflow
版权声明:本文标题:javascript - "$.cookie is not a function" error in FF eventhough I include it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741644106a2390085.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论