Skip to content

Instantly share code, notes, and snippets.

@killerbytes
Last active July 29, 2016 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerbytes/11167446 to your computer and use it in GitHub Desktop.
Save killerbytes/11167446 to your computer and use it in GitHub Desktop.
var delay = (function() {
var timer = 0;
return function(callback, ms) {
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
})();
$(window).resize(delay(function() {
someFunction()....
}, 500));
if (timer){
clearTimeout(timer);
}
timer = setTimeout(function(){
$.post("remote.php",{'partial':this.value},function(data){
$("#gen_results").html(data);
});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment