There is a button and when user clicks on button, some data is saved to back-end. Issue is when user clicks on button very quickly, event handler is getting executed multipl
Try the following code
var x = 1; var fewSeconds=10; /*10 seconds*/ $('#button').click(function() { $('#button').attr("disabled", "disabled"); x++; console.log(x); var btn = $(this); btn.prop('disabled', true); setTimeout(function(){ btn.prop('disabled', false); }, fewSeconds*1000); });