I want my user to receive the latest message that his/her chat mate has sent, so i used set interval and ajax and set the interval to 1 second, but i think it will cause lag in my database if I do that since it will continuously retrieve data every 1 second, I don't want it to have a minute of delay because it's a chat message. Is this the proper approach? If not what is the right way to do this?
You can use websockets or if you have a dedicated server you can try any XMPP server.
http://xmpp.org/xmpp-software/servers/
Thanks Pramod