简体   繁体   English

在MySQL数据库中更新页面时,如何立即(或尽快)更新页面上的值? (不刷新)

[英]How do I update a value on a page instantly (or ASAP) when it's updated in MySQL database? (without refresh)

Is there a way to pull a value from a MySQL database instantly (or within a second or less) when it is updated and display it on a page without refreshing the page? 有没有一种方法可以在更新时立即(或在一秒钟或更短的时间内)从MySQL数据库中提取值并将其显示在页面上而无需刷新页面?

The idea is that 2 people sitting at their computers are "racing" to update the value and whoever does it first "wins". 这个想法是,两个坐在电脑旁的人在“竞相”更新价值,而谁先取胜则是“赢”。 If User A clicks a link first, the value will update and User B will see the number change from 0 to 1 and his ability to click the link will disappear. 如果用户A首先单击链接,则值将更新,并且用户B将看到数字从0变为1,并且他单击链接的能力将消失。

I am good with clicking a link to change the value from 0 to 1, but I'm not sure how to make the value instantly change for the other guy once the value has already been changed. 我可以通过单击链接将值从0更改为1很好,但是我不确定一旦值已更改后如何立即让另一个人更改该值。

I'm starting to think this is just a bad idea for a web app. 我开始认为这对于Web应用程序来说不是一个好主意。 Regardless, I'd like to know how to do it if it's possible. 无论如何,我想知道如何做到这一点。

This might not be possible with mysql. 对于mysql,这可能是不可能的。 As mysql does not support realtime communication, it needs something like websockets. 由于mysql不支持实时通信,因此需要websockets之类的东西。

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

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