how to read cookies in jquery? -
i creating cookie key , value of object using carhartl’s jquery cookie plugin,in 1 of method call create cookie , right after call cookie;but read method doesn't work: makecookie methode:
function makecookie(name,value){ $.cookie(name,value); }
readcookie method:
function readcookie(name){ $.parsejson($.cookie(name)); }
and calling these 2 methods:
makecookie('chatpopups',popups); var all=readcookie('chatpopups'); alert(all);
popups global javascript object;
the error :
syntaxerror: json.parse: unexpected character @ line 1 column 2 of json data
can me?
please try code change in readcookie
function
readcookie method:
function readcookie(name){ return $.cookie(name); // no parse needed because not json object of cookie }
Comments
Post a Comment