I would like a add a 1-2 second delay on each iteration of the following loop.
You can do it this way with setTimeout()
:
$(document).ready(function() {
$('#start').click(function() {
//srPerformGeocode("TD Tower, 55 King Street West, Toronto, ON, Canada, M5K 1A2");
var x = 0;
function go() {
srPerformGeocode("TD Tower, 55 King Street West, Toronto, ON, Canada, M5K 1A2");
if (x++ < 20) {
setTimeout(go, 2000);
}
}
go();
return false;
});
});
This does make me wonder why you're doing a geocode lookup on the exact same address 20 times in a row?