31
rated 0 times
[
36]
[
5]
/ answers: 1 / hits: 37252
/ 13 Years ago, fri, january 27, 2012, 12:00:00
I have a list of javascript objects:
var people = [
{ 'name' : 'Abel', 'age' : 1 },
{ 'name' : 'Bella', 'age' : 2 },
{ 'name' : 'Chad', 'age' : 3 },
]
I tried to store them in a browser cookie with jQuery $.cookie():
$.cookie(people, people);
I then retrieve this cookie and then try to push another object into it:
var people = $.cookie(people);
people.push(
{ 'name' : 'Daniel', 'age' : 4 }
);
However, this does not work; I analyzed this code in Firebug, and Console noted that people
was a string ([object Object],[object Object],[object Object]
) and that the push function did not exist.
What is going on? What is the proper way to store and retrieve a list of objects?
More From » jquery