It is necessary to display new data recorded in the database without refreshing the page. There are two good examples in my opinion of this implementation:
- vk (receive new message)
- gmail (receiving a new letter)
So far I see only such a "dull" way to do it. jquery (ajax, post) updated by setinterval /,
$.post( "/ajaxtest.php", { param1: "param1", param2: 2 }, onAjaxSuccess ); function onAjaxSuccess(data) { // Здесь мы получаем данные, отправленные сервером и выводим их на экран. alert(data); } and it's all wrapped in a counter for example every 5 minutes.
Or create a cron on the server with a schedule and every 5 minutes access the script.php
but it seems to me that there are more interesting and correct decisions, maybe someone has come across such a thing, please help, to be honest, I don’t know how else this can be implemented, it’s very interesting. Thanks for attention!
VK&GMailuse long polls (yes, yes, an eternal loop throughsetTimeout). And even for new browsers do not throwWebSocket, just checked. - user207618