"is not a function" Error from Period Updater's Stop function

Go To StackoverFlow.com

2

$.PeriodicalUpdater.stop();

...gives me...

TypeError: Result of expression '$.PeriodicalUpdater.stop' [undefined] is not a function.

I've checked an double checked the owner's manual, I cannot figure out why this isn't working correctly. The error is harmless for the most part, it's just the user's browser won't stop making server calls that it no longer needs.

Thanks!

2012-04-04 17:19
by NominalAeon


1

The doc says

The function call returns a handle. You can call .stop() on this handle in order to stop the updating and ignore any subsequent responses. If the maximum number of calls, .stop(), or the autoStop has been triggered, you can restart the updater using .restart() on the handle. This handle is also passed into the callback function as the fourth argument.

so it should be

var handle =$.PeriodicalUpdater(url, options);
handle.stop();

EDIT - after your comments, try

$.PeriodicalUpdater( url, { options, function(remoteData, success, xhr, handle){ 
  if(condition){ 
     handle.stop(); 
   } 
});
2012-04-04 17:22
by Nicola Peluchetti
$.PeriodicalUpdater( url, { options, function(){ if(condition){ $.PeriodicalUpdater.stop(); } });

That's the context in which I'm using PU.stop(), does that change anything? It feels weird declaring a whole different PU inside the function of the PU I need to stop... What do you think? Thanks for your response, btw - NominalAeon 2012-04-04 17:55

@user1313446 the handle is passed as the fourth argument of the function, just call stop on that. I edited my answe - Nicola Peluchetti 2012-04-04 18:12
Thanks, Nicola, this is a huge weight off me shoulders - NominalAeon 2012-04-04 20:29


0

from manual

The function call returns a handle. You can call .stop() on this handle [...]

I think you must call stop() on handle.

ex:

var handle = $.PeriodicalUpdater('path',{},func);
handle.stop();
2012-04-04 17:27
by Luca Rainone
$.PeriodicalUpdater( url, { options, function(){ if(condition){ $.PeriodicalUpdater.stop(); } });

That's the context in which I'm using PU.stop(), does that change anything? It feels weird declaring a whole different PU inside the function of the PU I need to stop... What do you think? Thanks for your response, btw - NominalAeon 2012-04-04 17:56

The answer of Nicola is correct. You should accept it. ; - Luca Rainone 2012-04-04 19:21
Sorry, I'm new. So check mark that answer up there, right? Thanks, you guys for the responses - NominalAeon 2012-04-04 20:26
Ads