문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top