简体   繁体   English

没有Javascript的setTimeout()的数据库条目后刷新页面

[英]Refresh page after a database entry without Javascript's setTimeout()

Isn't there a way where I can refresh the page right after a database new entry WITHOUT using Javascript setTimeout or setInterval ? 没有一种方法可以在没有使用Javascript setTimeoutsetInterval的数据库新条目之后立即刷新页面吗?

Isn't there an AJAX function to do so? 没有AJAX功能吗? Or maybe a MySql function? 也许是MySql函数?

The only way is keep checking the database all the time? 唯一的办法就是一直检查数据库? Doesn't it spend too much of the server? 它不花费太多服务器吗?

My page will work like a Messenger. 我的页面将像Messenger一样工作。

You need to understand that what happens on the server and what happens on the client are completely separated, and while the client has a straight-forward way to contact the server , the converse is not true. 您需要了解,服务器上发生的一切与客户端上发生的一切是完全分开的,并且尽管客户端具有直接联系服务器的方式 ,但事实并非如此。 There's no way any MySQL function could possibly refresh the browser on the client machine. 任何MySQL函数都不可能刷新客户端计算机上的浏览器。

So polling (with ajax or similar) is frequently how this is done. 因此,轮询(使用ajax或类似方法)通常是这样做的方式。 However, it's not the only way. 但是,这不是唯一的方法。 There are various "Comet" techniques , and of course the new web sockets initiative. 有各种各样的“ Comet”技术 ,当然还有新的Web套接字倡议。

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

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