I want to periodically query a PHP script for new messages. To do so, I\'m using the setInterval() function and AJAX.
$(document).ready(function(){
var
Check your code line:
setInterval(getMessages(), queryInterval);
The setInterval function requires you to pass the reference to your callback function.
When you pass getMessages(), You are actually calling the function and passing its returning object to the setInterval function.
So just change your line to:
setInterval(getMessages, queryInterval);
and it will works fine!