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?
validateUserTimeanywhere. All you do is creating an object literal with one property but not assign it to anything. It just gets garbage-collected. Just define the variable properly:var validateUserTime = function ...;.