// start AJAX interaction with processCallback as the callback function
// callback for the request
// do post processing setTimeout("checkForMessage()", 10000);
Notice that the checkForMessage will continue to loop indefinitely. You may want to vary the increment the interval based on activity in the page or your use cases. You may also choose to have logic that would break out of the loop based on some AJAX response processing condition.