title: clearInterval() is not stopping setInterval() - Firefox Extension Development
body: <p>I am working on a modification of tamper data that will allow me to send the HTTP request/responses it observes to a server. So far, that functionality has been implemented correctly. The next step is to automate this process, and I wish to use a toolbarmenu button of type 'checkbox' to toggle this functionality on and off.</p>
  
  <p>So far I have this bit of code in the .XUL:</p>
  
  <pre><code>&lt;toolbarbutton id="tamper.autosend" label="&amp;tamper.toolbar.autosend;" type="checkbox" oncommand="oTamper.toggleTimer();"/&gt;
  </code></pre>
  
  <p>And this function in the main driver of my extension:</p>
  
  <pre><code>toggleTimer : function() {
   var checked = document.getElementById('tamper.autosend').checked;
  
   var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
  
   consoleService.logStringMessage(checked);
  
   if (checked) {
          var interval = window.setInterval(function(thisObj) { thisObj.sendResults(true); }, 1000, this);
   }
  
   else {
          window.clearInterval(interval);
   }
  }
  </code></pre>
  
  <p>Using the consoleService I see that the value of 'checked' is indeed correct. I believe the problem lies with how I am calling clearInterval, but I'm not exactly sure how to remedy it.</p>
  
  <p>Any help is greatly appreciated!</p>