Created
August 17, 2012 02:11
-
-
Save brianherbert/3375319 to your computer and use it in GitHub Desktop.
prevent multiple calls for map markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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