数据库输入后刷新页面没有Javascript的setTimeout()

数据库输入后刷新页面没有Javascript的setTimeout()

问题描述:

Isn't there a way where I can refresh the page right after a database new entry WITHOUT using Javascript setTimeout or setInterval?

Isn't there an AJAX function to do so? Or maybe a MySql function?

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.

我没有办法在数据库新条目之后立即刷新页面而不使用Javascript setTimeout em>或 setInterval em>? p>

是否有AJAX函数可以执行此操作? 或者也许是一个MySql函数? p>

唯一的方法是不断检查数据库? 它是不是花了太多的服务器? p> 我的页面将像Messenger一样工作。 p> div>

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.

So polling (with ajax or similar) is frequently how this is done. However, it's not the only way. There are various "Comet" techniques, and of course the new web sockets initiative.