简体   繁体   English

Web浏览器中的离线应用程序存储数据并上传后

[英]Offline application inside web browser storing data and uploading after

I need to build an application to run inside a web browser that works offline (whitout any internet connection) and store data in a way that I can after with internet connection be able to upload these data to a server. 我需要构建一个应用程序,以便在离线工作的Web浏览器中运行(不管任何互联网连接),然后以互联网连接后可以将这些数据上传到服务器的方式存储数据。

for example for example an HTML form 例如,例如HTML表单

<html>

<body>

    <form>

        Name: <input type="text" name="name" /><br />
        E-mail: <input type="text" name="email" /><br />

        <input type="submit" name="save" />
    </form>

</body>

so when I submit this form the browser saves the data somewhere and when I be connected I can upload it to a server... 因此,当我提交此表单时,浏览器会在某处保存数据,当我连接时,我可以将其上传到服务器...

do anybody knows a way to do that?? 有谁知道这样做的方法?

Use local storage to save offline data. 使用本地存储来保存脱机数据。 You can use AJAX (jQuery makes it easy: see here ) to try to post the local storage data to your server. 您可以使用AJAX(jQuery使其变得简单: 请参阅此处 )尝试将本地存储数据发布到您的服务器。 You may want to set an interval to post to the server. 您可能希望设置发布到服务器的间隔。

Saving to local storage (in browsers that support it) and then syncing with a web server is how I would do it. 保存到本地存储(在支持它的浏览器中),然后与Web服务器同步是我将如何做到这一点。

The real problem here is that browsers were not really build for that so you'll need to find some clever solutions and also would only work in modern browsers. 这里真正的问题是浏览器并不是真的为此而构建,因此您需要找到一些聪明的解决方案,并且只能在现代浏览器中使用。

A native application might be a better way to go. 本机应用程序可能是更好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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