如何刷新页面并保持元素不刷新(持久)直到用户单击提交? [英] how to refresh the page and keep elements non-refreshed (persistent) until the user clicks the submit?

查看:200
本文介绍了如何刷新页面并保持元素不刷新(持久)直到用户单击提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种jQuery的方法,以在刷新页面时使页面元素在用户屏幕上保持不变.当我刷新页面并丢失jQuery页面中的内容时,它会发生变化.

I'm looking for a jQuery way to keep elements of the page persistent on the user's screen while refreshing the page. It changes when I refresh the page and I lose the contents in the jQuery page.

我需要页面保持持久性.如何刷新页面并保持元素不刷新(持久),直到用户单击提交"按钮为止.该怎么办?

I need the page to be persistent. How to refresh the page and keep elements non-refreshed (persistent) until the user clicks the submit button. How can this be done?

推荐答案

由于刷新整个页面正在加载整个页面,因此,保存到目前为止输入到页面中的数据的唯一方法是将其保存下来刷新之前将其保存到某个存储位置,然后在加载新页面时,从存储位置读回它.

Since refreshing the whole page is loading a whole new page, the only way you can preserve the data entered so far into the page is to have already saved it off to some storage location before the refresh and then upon loading a new page, you read it back in from the storage location.

存储数据的可行位置是:

Feasible places to store data are:

  1. 饼干.
  2. 使用ajax调用从服务器进行存储(例如自动保存),然后通过ajax进行检索,或者让服务器在刷新时将保存的值放回表单中.
  3. 存储在HTML5网络存储中(仅适用于更新的浏览器).
  4. 存储在另一个窗口或框架(来自同一域)中,该窗口或框架未刷新.

另一种可能性是避免刷新页面.您没有说为什么要首先刷新页面,但这只是为了更新页面中的某些内容,然后您可以使用ajax来获取更新的内容,并使用jQuery将新内容放入页面并完全避免刷新.这样,页面中的现有数据将保持不变.

The other possibility is to avoid refreshing the page. You don't say why you are refreshing the page in the first place, but it it's just for the purposes of updating some content in the page, then you could use ajax to fetch the updated content and use jQuery to put the new content into the page and avoid the refresh entirely. Doing it that way, the existing data in the page would remain untouched.

这篇关于如何刷新页面并保持元素不刷新(持久)直到用户单击提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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