3

I have made pagination with jQuery and now I would like to save the selected state/page to cookie. I would need to save tab-id, offset and limit values.

I know that I can write to cookie like this:

$.cookie("example", "foo");

And then read it:

$.cookie("example");

But how I can save all those three thing into cookie? And especially read it?
For example, if I need to know just the tab-id value from the cookie, how can I get that if I have multiple values in cookie?

Also all help/info on how to do a saving page state (pagination) is appreciated.

And jQuery site is down, I checked that first
:p Thanks.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295

1 Answers1

2

You can either set 3 different cookies, or create a JSON object and store that string as your one cookie.

Coach John
  • 307
  • 1
  • 4
  • 11
  • I have no clue how to create JSON object. Any good examples anywhere? – Thom Eriksson Sep 08 '10 at 19:14
  • Read this: http://api.jquery.com/jQuery.getJSON/ It tells a bit about jow jQuery works with JSON, and theres a really simple example there that actually is kind of close to what you'd want to do. – Coach John Sep 08 '10 at 20:20