clumsygenius Posted June 14, 2011 Share Posted June 14, 2011 Lets say you want a little exclamation mark to appear next to mail logo of the page to let the user know that they have new mail. you want this to automatically pop up when they get mail without them having to refresh. I KNOW I can use Ajax to periodically send requests to the server and check for new mail. but I was wondering if there is a way to make the client side just listen, and have the server send it an update whenever new mail comes in. Thaks Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 14, 2011 Share Posted June 14, 2011 No. Quote Link to comment Share on other sites More sharing options...
clumsygenius Posted June 14, 2011 Author Share Posted June 14, 2011 What about in the case of instant messengers like the one in gmail or facebook? when a message a sent, the recipient receives it within a second. So does client side script send requests multiple times a second to check for new incoming instant messages? that seems a little wasteful. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 14, 2011 Share Posted June 14, 2011 What about in the case of instant messengers like the one in gmail or facebook? when a message a sent, the recipient receives it within a second. So does client side script send requests multiple times a second to check for new incoming instant messages? that seems a little wasteful. AJAX. Wasteful? Not really. In the case of an IM app, the AJAX request itself is insignificant. It probably only needs to sent the ID of the conversation and the ID if the user. If there is no new content (as would be the case in 99.99% of the requests) the server would simply return a false value (i.e. a zero) or maybe a little other info. That would take a whole whopping single bit of data. An email client would be no different. It is only when there is new data that any significant data would be returned, which is what you want anyway. It *may* be wasteful on the server, which is why you would write the code to be as efficient as possible. But, that is also why services like Google have thousands of server to support their products. If you want to validate all of this for yourself. Download an app called Fiddler. It is a little complicated to use, but it will show you all incoming/outgoing transmissions from your computer. With it I'm sure you will be able to see the multiple AJAX calls that are taking place. Quote Link to comment Share on other sites More sharing options...
clumsygenius Posted June 14, 2011 Author Share Posted June 14, 2011 I see. thank you for the detailed response. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.