Answer the question
In order to leave comments, you need to log in
Update news feed via ajax?
There is a news feed in which users can post various news. Is it possible to make it so that when a user adds news, other users viewing the feed will have this news added via Ajax? I have no idea which way to go. I write in php and use jquery.
Answer the question
In order to leave comments, you need to log in
Try reloading news from api.jquery.com/jQuery.ajax/ and www.w3schools.com/js/js_timing.asp.
For example:
function refresh_func()
{
$.ajax(...).
success(function(){
...
});
}
setTimeout("refresh_func();", 10000);
Dig by Comet keywords
For example: dklab.ru/lib/dklab_realplexor/
rutvit.ru/ - an example of a project
In theory, websocket was created for this, but in my opinion it really works only in flash, and in most browsers support was removed by default.
There is another option to make a timer and use Ajax to request updates from the server once in a while, but such a thing with a large number of clients will turn them into a botnet that will lay down your site.
You can play around with keepalive connections, but I have little idea how to make such functionality off the counter on them.
as an option, they suggested using a comet server or websockets.
The very idea of comet technology изврат
is a gag of the imperfection of the HTTP protocol. But it works and can be applied.
There is a problem with websockets, as they are not stable. They found a hole in the implementation of the websocket protocol, and made a fuss, as a result of which most web browser manufacturers temporarily removed them. Not all servers support websockets.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question