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

I have a simple html page and a 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 my name and when I hit refresh to show my name. The only problem is when I try to read the cookie, instead of name shows %5Bobject%20Object%5D.

Thank you.

Answers


do:

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

Updated:

try adding:

$.cookie.raw = true;

Need Your Help

How can i take one attribute of my model and put it in a option element attribute of a activeDropDownList?

yii

In de documentation for activeDropDownList() -> $htmlOptions says this: options: array, specifies additional attributes for each OPTION tag. The array keys must be the option values, and the array ...

Could not find property 'allJava' on source set main

java android gradle android-studio

Hy, I am using Android Studio 0.6.0 as of this morning, during the upgrade process I had to switch to Gradle version 0.11 to compile my Android project.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.