如何动态保存Web应用程序状态? [英] How to save a web-application state dynamically?

查看:124
本文介绍了如何动态保存Web应用程序状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Web应用程序,用户可以将图像和文本拖放到 div 或类似的容器中。然后,当用户单击保存按钮时,应用程序将能够保存已删除项目的内容以及这些项目的位置信息。

I would like to create a web application where a user can drag and drop images and text onto a div or similar container. Then, when the user clicks a save button, the application would be able to save the content of the dropped items, as well as the positional information for those items.

最终用户应该能够返回,打开然后应用程序,并将图像和文本放回到与保存时完全相同的位置。

Ultimately the user should be able to come back, open then application, and have the images and text back in the exact same places as when they were saved.

如果有人知道可以帮助完成此任务的方法或框架,我们将不胜感激。

If anyone knows a methodology or framework that could assist in accomplishing this, it would be appreciated.

推荐答案

当用户点击保存按钮时,您需要收集当前网页的动态状态(听起来像图像和位置)并使用某种用户ID将其发送到您的服务器唯一且安全地识别该用户。用户下次加载此网页时,您可以将状态放入网页,因为它是从服务器检索的,或者您可以使用客户端javascript从服务器检索该用户的状态,然后动态地将页面修改为匹配所需的状态。

When the user hits the save button, you will need to collect the dynamic state of the current web page (which sounds like images and positions) and send that to your server with some sort of user id that uniquely and securely identifies this user. The next time that user loads this web page, you can either put the state into the web page as it is retrieved from the server or you can use client-side javascript to retrieve that user's state from the server and then dynamically modify the page to match the desired state.

您可以使用ajax调用或帖子将状态保存到服务器。您可以使用ajax调用从客户端javascript检索服务器中的状态,或者如果服务器已将状态放入网页,您可以在那里引用它。

You can save the state to the server with either an ajax call or a post. You can retrieve the state from the server from the client javascript using an ajax call or if the state was already put into the web page by the server, you can just refer to it there.

这篇关于如何动态保存Web应用程序状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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