Steve
Steve

Reputation: 21499

Stop JQuery refreshing DIV

Hi I've been using the suggestion made in Auto-refreshing div with jQuery - setTimeout or another method? to refresh a div. The div is refreshing a php script that is calculating lots of numbers in the background.

Does anyone know how I can stop the DIV refreshing once a the calculation in the php script have finished loading?

Upvotes: 0

Views: 738

Answers (2)

user499054
user499054

Reputation:

You can use a simple boolean or just an if statement.

finished = false;

function update()
{
   if ( finished )
      return;
   else
   {
      // continue calculating and call again
      window.setTimeout( update, 10000 );
   }   
}

Upvotes: 1

Mike Lewis
Mike Lewis

Reputation: 64147

Assuming your timer is called timer, you can call the following to cancel the timer that refreshes the div.

clearTimeout(timer);

Upvotes: 1

Related Questions