javascript - jQuery cookie value is %5Bobject%20Object%5D -


i have simple html page , js script: html page:

<body> <input type="text" id = "content"> <button type="button" id="btn"> save </button> </body> 

javascript:

$(document).ready( function(){     var cook = $.cookie('thename',  { path: '/'});      if ( cook )         alert(cook);      $('#btn').click(function(){         var thename = $('#content').val();         alert(v.val());         $.cookie('thename', thename, { path: '/', expires: 7 });         alert("cookie done");     }); }); 

libraries:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"> </script> <script type="text/javascript" src = "https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js"> </script> 

it should save name , when hit refresh show name. problem when try read cookie, instead of name shows %5bobject%20object%5d.

thank you.

do:

$(document).ready( function(){     var cook = $.cookie('thename'); //get cookie if exists      if ( cook )         alert(cook);      $('#but').click(function(){         var thename = $('#content').val();         alert(thename);         $.cookie('thename', thename, { expires: 7, path: '/' }); //set cookie         alert("cookie done");     }); }); 

updated:

try adding:

$.cookie.raw = true; 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -