I need guidance in PHP Ajax.
I want to develop feature something like Gmail.
Now here we go.
I have two page one is login and second is display.
Once login user will redirect to display page where he can see messages send from other user.
Now I want to implement ajax like whenever user send message to other user then other user immediately notify that he/she got message and also need to append it to their mail box.
I know I can do it using setInterval but is there other way because setInterval might be for either 5 sec or 10 sec but I want to fire it whenever other user send him message.
I see this in zaarly.com and Gmail form.
Thanks in advance.
Ajax is a browser-side technology. It doesn’t have the ability to receive messages from the server without the browser asking for them. If you want to use Ajax for this, then you need to have it ping the server regularly using a solution along the lines of the one you suggested using
setTimeoutor similar.In fact Ajax is the wrong term for this sort of thing. The term you need to search for is actually known as Comet. You can read more about it here: http://en.wikipedia.org/wiki/Comet_%28programming%29.
Comet is a catch-all term for server-push-to-the-browser technology. Your solution is one of many possible implementations for Comet, although it isn’t particularly efficient in terms of bandwidth. The wiki page linked above lists a number of other possible ways of achieving your goal, which you may want to investigate. But googling for ‘Comet’ rather than ‘Ajax’ will definitely help your research here.
Hope that helps.