In Facebook. you get notifications, when somebody sends you a message. This is done without the user doing nothing. How is it triggered?
Can I achieve something like that using jsp, jQuery - ajax ?
How is that possible. Because I normally do things based on key press, or when user refreshes his browser. How can you know when that you receive a message?
There are plenty methods for a server to send messages to a client. Some are:
XmlHttpRequest's onreadystatechange is (ab)used to allow the server to 'stream' events, notifications, and other live data to the browser. This is now deprecated, but is the most compatible method. See http://en.wikipedia.org/wiki/Comet_(programming))I would suggest using the jQuery EventSource plugin, which uses server-sent events when available, and, when not available, falls back to Comet: https://github.com/rwldrn/jquery.eventsource
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With