100
rated 0 times
[
105]
[
5]
/ answers: 1 / hits: 34184
/ 13 Years ago, wed, february 1, 2012, 12:00:00
I would like a add a 1-2 second delay on each iteration of the following loop.
<html>
<script type=text/javascript src=http://maps.googleapis.com/maps/api/js?sensor=false></script>
<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js></script>
<input id=start type=submit> </input>
<div id='status'></div>
<script>
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<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 + <br/>);
}
else{
$('#status').prepend(Failed : + address + <br/>);
}
});
}
}
</script>
More From » loops