Search code examples
jqueryhtmlcookiesappendclone

Save html in cookie


I am using jquery to clone and append some html into a div.

My problem is that this html will be removed when the page is refreshed. The question is how I can save the appended HTML in the div (the html code will contain some inputs and select lists and there will be plenty of code).

What should I look into?

Cookies?

HTML5?

Anything else?


Solution

  • If you're only going to support modern browsers I would go for HTML5's offline storage.

    Another approach would be to get the AJAX route.

    You don't want to use cookies for this, bacause:

    cookies get loaded at every request

    cookies can only hold limited amount of information.