title: how to slow down a javascript loop
body: <p>I would like a add a 1-2 second delay on each iteration of the following loop.</p>
  
  <pre><code>&lt;html&gt;
  &lt;script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;input id="start" type="submit"&gt; &lt;/input&gt;
  &lt;div id='status'&gt;&lt;/div&gt;
  
  &lt;script&gt;
  var geocoder=new google.maps.Geocoder();                   
  var glGeocodeCount = 0 ;
  
  $(document).ready(function() {
  
      $('#start').click(function() {
  
          //srPerformGeocode("TD Tower, 55 King Street West, Toronto, ON, Canada, M5K 1A2");      
  
          for(x=0;x&lt;20;x++){
              srPerformGeocode("TD Tower, 55 King Street West, Toronto, ON, Canada, M5K 1A2");
          }
          return false;
      });          
  }); 
  
  function srPerformGeocode(address){     
      if (geocoder){                
          geocoder.geocode({ 'address': address }, function (results, status) {                                                                              
              if (status == google.maps.GeocoderStatus.OK){                                                                                                                                                                           
                  $('#status').prepend("Success : " + address + "&lt;br/&gt;");
  
              }
              else{
                  $('#status').prepend("Failed : " + address + "&lt;br/&gt;");
  
              }
          });
      }
  }
  &lt;/script&gt;
  </code></pre>