0

Hi All,
I have web page where the datas are refreshed by calling Asp.net web service from javascript. I am using javascript setInterval() for updating the datas periodically, also using clearInterval() for stopping this javscript timer. In total the page gets details from 3 different web services. Once the data is received the setinterval delay will be set to 20 seconds(initial setInterval delay is 2 seconds). But some times even after receiving the data and setting the setinterval delay to 20 seconds, setInterval calls continuously. Please help me to solve this issue.

Thanks

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by essential
0

Here's a little demo about clearing the timer in the given funtion:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<HTML lang="en">
<HEAD>
<META http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>Clear Interval DEMO</TITLE>
<SCRIPT type="text/javascript">
<!--
var time, timer, counter;
counter = 21;

Function.prototype.count = function( DELAY ) {
return setInterval( this, DELAY );
}

timer = function() {
   if ( counter ===  0 ) { 
    clearInterval( time );
      { return alert( "The timer has been cleared!" ); 
      } 
   } div = ( document.getElementById ) ? document.getElementById("output") : document.all.output; 
   return div.innerHTML = ( counter -= 1 );
}

window.onload = function() {
time = timer.count( 1000 );
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID="output"></DIV>
</BODY>
</HTML>
0

Essential,
My issue is even after clearing the timer the timer doesn't stops.
For checking this particular issue i put a button which fires the
clearInterval() on clicking. Then i simulate the condition again,
when the issue occures again i clicked the button for clearing the
timer,also i put an alert box before and after the clearInterval(), still
the timer is not stoping.
Thanks

0

It will be easy for us to provide you the exact script that you need, if you are willing to post the code concerning this issue.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.