I am using the following code to display latest message in a template. This works great however it requires a page refresh to update.
` http://pastebin.com/WSWXSpJb
The main purpose of this script is to display latest unread messages and it should update via ajax means if user receive any message, latest unread messages without reloading page.