title: clearInterval and setting variable to null not working
body: <p>Despite having <code>supportchatinterval = null;</code> AND <code>clearInterval(supportchatinterval);</code> in my code below (see <code>onBlur()</code> and <code>onFocus()</code> ) every 5000ms the function is still loading getTableSupport.php at the same setInterval (see <code>checkForChangesSupport()</code>. When the function onBlur is set I want to stop the setInterval until <code>onFocus</code> is called again.</p>
  
  
  
  <pre><code>&lt;script&gt;
  
  supportchatinterval = 5000;
  
  $(document).ready(function(){
      checkForChangesSupport();
      setTimeout(checkForChangesSupport, supportchatinterval);
  });
  
  function checkForChangesSupport() {
     $.get("getCountSupport.php", function(response) {
        if(response == 1) {
           refreshTableSupport();
        }
  setTimeout(checkForChangesSupport, supportchatinterval)
     });
  }
  
  function refreshTableSupport(){
      $('#tableHolderSupport').load('getTableSupport.php');
  }
  
  &lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function onBlur(){
  document.body.className = 'blurred';
  $.get("afk.php?afk=1");
  supportchatinterval = null;
  clearInterval(supportchatinterval);
  };
  
  function onFocus() {
  document.body.className = 'focused';
  $.get("afk.php?afk=0");
      supportchatinterval = 5000;
  refreshTableSupport();
  }
  
  &lt;/script&gt;
  </code></pre>