/    Sign up×
Community /Pin to ProfileBookmark

How to Stop PeriodicalUpdater in prototype.js?

I have several calls to PeriodicalUpdater on my page. These refresh the content within a <div> tag every minute. The problem is that there are times where I want the updates to stop. The weak documentation on prototype.js makes mention of it but I have no idea how to implement it. Has anyone been able to do this?

My code is simple really. I have about 4 calls to the following function for different <div>s. All four update at different times.

<script type=”text/javascript” language=”JavaScript”>
function fetchupdate(url,pars,tag,methtype,interval,decaymultiplier)
{ var myAjax = new Ajax.PeriodicalUpdater(tag,url,{method: methtype,parameters: pars,asynchronous: true,frequency: interval, decay: decaymultiplier});}
</script>

and I make the calls to the function on load like this:

fetchupdate(‘/ping/panel_l_whosout.php’,”,’whosout’,’post’,120.0,1);

How can I write a javascript function to selectively choose the particular fetchupdate tand stop it’s PeriodicalExecuter from runng?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JoeJoeJun 22.2009 — Well, you need to first store those PeriodicalUpdater objects and I guess you have some kind of conditions to test. Just call the stop method on those objects.

http://joekuan.wordpress.com/2009/06/22/ajaxprototypejson-periodicalupdater-a-working-example-log-update-on-a-background-process-part-12/

Hope this help
Copy linkTweet thisAlerts:
@bcamp1973Aug 06.2009 — I'm trying to tackle the same problem. It's supposed to stop when a value of -1 is returned. How so i accomplish this?

risk.startPolling = function(button){
var report_id = $(button).metadata().report_id;

<i> </i> $.PeriodicalUpdater('/report/stagei/risk_reports/progress/'+report_id, {
<i> </i> method: 'get',
<i> </i> data: '',
<i> </i> minTimeout: 2000,
<i> </i> maxTimeout: 8000,
<i> </i> multiplier: 2,
<i> </i> type: 'text'
<i> </i> }, function(data) {

<i> </i> /*
<i> </i> The progress value is at -1 if it is currently not running. Running starts at zero and runs to zero, but
<i> </i> when completed goes to -1
<i> </i> */
<i> </i> if(data &gt;= 0) {
<i> </i> // update the bar to the new percentage
<i> </i> $($(button).metadata().target+' div')
<i> </i> .animate({
<i> </i> width: data+'&amp;#37;'
<i> </i> },200);
<i> </i> } else {
<i> </i> // Stop running!!!
<i> </i> }

<i> </i> });
<i> </i>}


BTW, i'm using jquery so that explains the $() etc...
Copy linkTweet thisAlerts:
@bcamp1973Aug 06.2009 — P.S. I've tried "clearTimeout(PeriodicalTimer);" at http://www.360innovate.co.uk/blog/periodical/ but it doesn't work for me at all...i'm scouring the 'net for the solution, but everything i try fails ?
×

Success!

Help @cluettr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...