简体   繁体   English

在为 mySQL 查询构建工作订单时,localStorage 是 go 的好方法,用户是否离线?

[英]Is localStorage a good way to go when building an workorder for mySQL query is user is offline?

I'm building a web app that will update MySQL when the user comes online.我正在构建一个 web 应用程序,该应用程序将在用户上线时更新 MySQL。

I have this form where the user enters data.我有用户输入数据的表单。
The formData saves into "localStorage" is the user is offline and when the user goes online a javascript is fetching data from the localStorage and then send it through AJAX to PHP and MySQL. The formData saves into "localStorage" is the user is offline and when the user goes online a javascript is fetching data from the localStorage and then send it through AJAX to PHP and MySQL.

Is this a way to go or are there better ways to create a list for offline users?这是 go 的一种方法,还是有更好的方法为离线用户创建列表?

I'm also using a serviceWorker to cache the static html and js pages.我还使用 serviceWorker 来缓存 static html 和 js 页面。

//ADD DATA TO localStorage (data contains the formData)
localStorage.setItem(id, JSON.stringify(data));

//FETCH DATA (this is in a loop)
JSON.parse(localStorage.getItem(key));

I guess it is..我猜是..

I did this and it works good我这样做了,效果很好

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

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