{"id":5560,"date":"2014-04-01T02:48:31","date_gmt":"2014-04-01T02:48:31","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/01\/clearinterval-is-not-stopping-setinterval-firefox-extension-development-collection-of-common-programming-errors\/"},"modified":"2014-04-01T02:48:31","modified_gmt":"2014-04-01T02:48:31","slug":"clearinterval-is-not-stopping-setinterval-firefox-extension-development-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/01\/clearinterval-is-not-stopping-setinterval-firefox-extension-development-collection-of-common-programming-errors\/","title":{"rendered":"clearInterval() is not stopping setInterval() &#8211; Firefox Extension Development-Collection of common programming errors"},"content":{"rendered":"<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 &#8216;checkbox&#8217; to toggle this functionality on and off.<\/p>\n<p>So far I have this bit of code in the .XUL:<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>And this function in the main driver of my extension:<\/p>\n<pre><code>toggleTimer : function() {\n var checked = document.getElementById('tamper.autosend').checked;\n\n var consoleService = Components.classes[\"@mozilla.org\/consoleservice;1\"].getService(Components.interfaces.nsIConsoleService);\n\n consoleService.logStringMessage(checked);\n\n if (checked) {\n        var interval = window.setInterval(function(thisObj) { thisObj.sendResults(true); }, 1000, this);\n }\n\n else {\n        window.clearInterval(interval);\n }\n}\n<\/code><\/pre>\n<p>Using the consoleService I see that the value of &#8216;checked&#8217; is indeed correct. I believe the problem lies with how I am calling clearInterval, but I&#8217;m not exactly sure how to remedy it.<\/p>\n<p>Any help is greatly appreciated!<\/p>\n","protected":false},"excerpt":{"rendered":"<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 &#8216;checkbox&#8217; to toggle this functionality on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5560","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5560"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5560\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}