title: JavaScript multiple intervals and clearInterval
body: <p>I have a small program, when you click on an "entry", the editing mode is opened, and the entry is to edit locked for others. There is every 10 seconds sends an ajax request to update the timestamp in the table.</p>
  
  <pre><code>$(".entry-edit").click(function() {
    // code
  
    loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);
  
    // code
  });
  </code></pre>
  
  <p>Then I have a cancel button to updating the timestamp in  the table to 0 and to clear the interval.</p>
  
  <pre><code>$(".entry-cancel").click(function() {
    // code   
  
    clearInterval(loopLockingVar);
  
    // code
  });
  </code></pre>
  
  <p>It all works when editing only one entry, but if two or more processed simultaneously, and then click cancel, the interval for the first entry still further...</p>
  
  <p>I have this tried:</p>
  
  <pre><code>var loopLockingVar;
  $(".entry-edit").click(function() {
    // code
  
    if( ! loopLockingVar) {
      loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);
    }
  
    // code
  });
  </code></pre>
  
  <p>However, this does not work more if you cancel and again clicks on edit...</p>