Hey
Im trying to make my ajax chat slightly more effective by only loading the chat script when an update occurs thus it doesn't need to keep loading it if nothing has changed in the database.
So i was wondering if you could help explain how to do this.
Currently my logic has:
JS function to get chat logs setinterval calls the function every half a second.
Now if nothings changed i see it as rather inefficient to keep calling it.
So i wanted to do the logic of JS function > check if theres new logs in database¬ IF YES - load new logs IF NO - leave the logs displayed as is.
How would i do that though... the function i use is :
function updateShouts(){ $('#chatArea').load('chat.php'); // load chat logs } setInterval( "updateShouts()", 500 ); //call function every half a second