Skip to content

Instantly share code, notes, and snippets.

@brianherbert
Created August 17, 2012 02:11
Show Gist options
  • Save brianherbert/3375319 to your computer and use it in GitHub Desktop.
Save brianherbert/3375319 to your computer and use it in GitHub Desktop.
prevent multiple calls for map markers
var lockCounter;
function ajaxCallFunc()
{
lockCounter++;
var check = lockCounter;
setTimeout(function(){
if (check == lockCounter)
{
// This request was the last one to increment the counter
// Bump up the counter so we can't fire another request
// while we fill this one
lockCounter++;
// PERFORMS AJAX STUFF HERE
}
},1000);
}
ajaxCallFunc(); // ignored
ajaxCallFunc(); // ignored
ajaxCallFunc(); // runs
// Wait a second or more
ajaxCallFunc(); // ignored
ajaxCallFunc(); // runs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment