Reputation: 20895
I am trying to set a cookie with jQuery 1.7.1:
var global_namesArray = ["Alex", "Bob", "Carmen"];
$.cookie("namesArray", global_namesArray);
I retrieve this cookie like this:
if ($.cookie("namesArray") != null)
global_namesArray = $.cookie("namesArray");
However, the page's javascript does not load. When I use Firebug to analyze my page, the console reads that $.cookie() is not a function. The error occurs during cookie retrieval I believe. I am sure that I have linked jQuery.
Am I using the jQuery $.cookie() function correctly?
Upvotes: 2
Views: 3200
Reputation: 95017
Make sure that jquery.cookie.js
is included after jquery.js
, and that you are not including jquery.js
more than once.
Upvotes: 1
Reputation: 6181
.cookie is not a native function for jQuery. Do you have the cookie plugin installed?
Edit: I just tested, and I get this error if I include jQuery but not the cookie plugin:
"$.cookie is not a function".
You probably just need to add the cookie plugin.
Upvotes: 5