I have just started studying Ajax for making my own chat application using MySQL, PHP, JavaScript and Ajax.
I have almost made my application but the problem is that I have used setInterval
so my box in which chat log is displayed it is fetched from the database every second and displayed,and this is inefficient.
Rather I want that the database is accessed only when there is some change in the database ,that is, when a user sends a message and the database is changed then only the database is fetched by other users message box.