8
rated 0 times
[
14]
[
6]
/ answers: 1 / hits: 23301
/ 13 Years ago, wed, january 4, 2012, 12:00:00
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 queryInterval = 1000; /* How fast we query for new messages */
setInterval(getMessages(), queryInterval);
function getMessages() {
console.log(tick);
}
});
However, when I look at the Javascript console, I'm only seeing tick once. I've made sure that the console doesn't ignore any more logs of the same strings, so if the code was working properly it should show tick in the console every second.
Anyone know what could be going wrong here?
More From » setinterval