Thursday, 5 September 2013

Trouble with the jquery cookie plugin

Trouble with the jquery cookie plugin

I have this
<button class="create">create</button>
<button class="check">check</button>
and
$(document).ready(function() {
$("#set_state").change(function() {
var theState = $(this).val();
$.cookie('set_state', theState, {
expires: 5,
path: '/'
});
});
$(".check").click(function() {
alert("Your Selected Value from Cookie is : " + $.cookie('set_state'));
});
$(".delete").click(function() {
$.cookie('set_state', '', {
expires: -1
});
$("#set_state").val("");
alert('Cookie is deleted now, try to get cookie..!');
});
});
which I got from another thread. I am very new to this and I can't figure
out why my alert reads "Your Selected Value from Cookie is : undefined".
What am I missing?

No comments:

Post a Comment