将 html 保存在 cookie 中 [英] Save html in cookie

查看:42
本文介绍了将 html 保存在 cookie 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery 克隆一些 html 并将其附加到一个 div 中.

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

我的问题是当页面刷新时这个html会被删除.问题是我如何将附加的 HTML 保存在 div 中(html 代码将包含一些输入和选择列表,并且会有大量代码).

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).

我应该注意什么?

饼干?

HTML5?

还有什么吗?

推荐答案

如果你只打算支持现代浏览器,我会选择 HTML5 的离线存储.

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

另一种方法是获取 AJAX 路由.

Another approach would be to get the AJAX route.

您不想为此使用 cookie,因为:

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

每次请求都会加载 cookie

cookies get loaded at every request

cookies 只能保存有限的信息.

cookies can only hold limited amount of information.

这篇关于将 html 保存在 cookie 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆