"$.cookie is not a function" error in FF eventhough I include it
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 commented $(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 applica开发者_StackOverflow社区tion).
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[]) 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>
Check 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 ?
精彩评论