简体   繁体   中英

Best way to store data clientside

I would like to store data temporarily on clientside. What is the best way to do this? I only want to store a small amount, which will probably just be an integer.

It does not matter if this data is lost when the browser is closed, if the session is closes, of the user navigates to another page etc etc. I just need it so I can access the value later on while the user is still on that page. The data needs to be stored when the page loads.

Is it best to use a hidden input field, cookie, jquery.data (don't really know much about this so this may not fit in here), or some other method?

To be more specific, the user will be selecting an item from the database, s/he will edit the data sent back, the id will also be sent back, then when they click save, i need to know the id so the edited data can be saved back to the database updating the row based on the id originally selected.

隐藏字段很好,如果您将数据作为表单的一部分提交,则它可能是首选。

如果在current pagerequired该值,则Hidden Fieldhidden input field, cookie, jquery.data Best选项

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM