title: setInterval and Ajax
body: <p>I have this problem when I use <code>setInterval</code> and ajax for retrieving data from the database and if the data that I retrieve from the database is equal to saveHere then it will loop again until it does not match the variable saveHere, it freeze the browser until the data that I retrieve is not equal to saveHere.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>var saveHere = 'RED';
  var interval = setInterval(function() {
  
      var sample = $.ajax({
          type: 'GET',
          url: 'database.php',
          data : data
      }).responseText;
  
      if (sample != 'RED') {
          clearInterval(interval);
          saveHere = sample;
      }
      else {
          console.log('load again');
      }
  
  },1000);
  </code></pre>
  
  <p>I really need advice. Thank you in advance. Sorry for the grammar.</p>