What I want to do is when 1 user checks a checkbox(just for example, it can be any event), everyone, who have same page opened, immediately saw it without page refresh.
I know how to do it with ajax and setTimeOut(or setInterval) function: with setTimeOut function we open stream where an infinite loop checks if an event was triggered and if yes, we update content with ajax. Or set interval to update page in some time.
I’m looking for more optimized and cross-browser solution, so any help will be appreciate.
Search google for: Comet or long polling
For the solution to be cross-browser, you have to bend what web-servers/HTTP were designed for, which is for requests from browsers being served a page as quickly as possible, and then closing the connection. There are new methods with new browsers, and new definitions in the HTTP model, but they will not work on old browsers.
The basic principle behind long polling, is that a request is sent to the server, which idles around, pretending to be generating the page, and if any event happens requiring the client to be updated, it then sends the information as the response to the request which pre-dated the request. This is inefficient in terms of server resources, but about as snappy as you can get in terms of user experience.