I have the following code:
XService.start = function() {
setInterval("XService.poll()", XService.pollInterval); }
This works great. However, when I do this (passing function as reference instead of having the string eval’d) it stops working:
XService.start = function() {
setInterval(XService.poll, XService.pollInterval); }
Why? What am I doing wrong? Nothing else changes in my code. I also tried XService.poll() in the second version but no dice either. The documentation I read said leave the () out.
Help?
Edit: XService.poll is a function; XService.pollInterval is a number. Both are declared and assigned correctly.
Edit2: The XService code:
XService = {};
XService.pollUrl = "/Poll";
XService.pollInterval = 60000;
XService.poll = function() {
$.get(this.pollUrl, null, null, "text"); }
XService.start = function() {
setInterval(XService.poll, XService.pollInterval); }
is XService.poll a ‘function’ and ‘XService.pollInterval’ a number at that specific time?
Edit: Since you posted the code just now..