title: jQuery Countdown plugin and AJAX
body: <p>I'm using <a href="http://keith-wood.name/countdown.html" rel="nofollow noreferrer">jQuery Countdown plugin</a> to implement a Countdown and call a webservice when timer expires.</p>
  <p>The problem is that I'm using AJAX on the page, and have to re-setup the Countdown on every AJAX request like so:</p>
  <pre><code>var prm = Sys.WebForms.PageRequestManager.getInstance();
  
  prm.add_endRequest(SetupTimer);
  
  /*Initial setup*/
  $(document).ready(function() {
      SetupTimer();
  });
  
  function SetupTimer() {
          var serverTime = new Date();
          var cutoffTime = new Date($(&quot;#&lt;%= cutoffTime.ClientID %&gt;&quot;).val());
          serverTime.setHours(serverTime.getHours());
          if (serverTime &lt; cutoffTime) {
              $('#timer').countdown('destroy'); /*should work, but doesn't*/
              $('#timer').countdown({ until: cutoffTime, serverTime: serverTime, onExpiry: OrderingEnded, format: 'yowdHMS' });
          } 
          else
              OrderingEnded();
      }
  </code></pre>
  <p>This, for some reason, creates a new instance of the Countdown on ever request, resulting in numerous calls to Webservice when Countdown expires.</p>
  <p><strong>How do I make sure that only one instance of the Countdown exists at a time?</strong></p>
  <h3>EDIT</h3>
  <p>found this in documentation, doesn't do it for me though</p>
  <pre><code>        $('#timer').countdown('destroy');
  </code></pre>