本地存储到MySQL
有没有简单的方法可以通过回调将数据从 localStorage 或 sessionStorage 移动到 MySQL 数据库?
我猜这可以通过 AJAX 来完成,但我找不到很好的操作方法或指南。基本上,我想将 localStorage 发送到服务器,并提醒用户服务器是否成功将数据存储到 MySQL 中。
Is there any easy way to move data from localStorage or sessionStorage into a MySQL database with callbacks?
I'm guessing this would be done with AJAX, but I can't find a good how-to or guide for it. Basically, I'd like to send localStorage to the server, and alert the user as to whether or not the data was successfully stored by the server into MySQL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经有一段时间没有搞过这个了,但是
localStorage
基本上只是一个对象,对吧?这意味着它可以作为 JSON 发送?因此,您可以构建对 PHP 页面的 AJAX 调用,发送 JSON,然后(在 PHP 对其进行处理并尝试插入它并回显结果之后)提醒用户什么发生了,对吧?(显然,您可以使用任何服务器端语言来完成此操作。)
It's been a while since I messed around with this, but
localStorage
is basically just an object, right? Which means that it could be sent as JSON? So you could construct an AJAX call to a PHP page, send the JSON, and then (after the PHP has messed with it and tried to insert it andecho
ed the result) alert the user as to what happened, right?(Obviously, you could do this with any server-side language.)