I try to request an URL every 5 seconds. The following code is returning ReferenceError: Can't find variable: validateUserTime
$(document).ready(function() {
({
validateUserTime: function() {
return $.get('/myurl', function(data) {});
}
});
return window.setInterval((function() {
validateUserTime();
}), 5000);
});
I’m wondering what I’m doing wrong that is preventing a call to the method instead of doing it as a variable. Any idea?
In the first statement, you are using an object literal without assigning it to anything.
Assign it to something to fix it.