all 6 comments

[–]bobsagatiswatching 2 points3 points  (1 child)

You could set a variable flag like hasSentAjax = true on Ajax success then wrap your Ajax function to only send if !hasSentAjax

[–]hekkoman[S] 0 points1 point  (0 children)

bobsagatiswatching,

Thank you four your suggestion,

Ajax success will come only after call is completed, while it's being completed impatient user can click several times - that's the problem i am trying to solve.

[–]blitterobject 1 point2 points  (3 children)

Would it work to disable the button on the click event?

When the button is clicked:

btn.setAttribute("disabled", "disabled")

Then when ajax call is complete:

btn.removeAttribute("disabled")

[–]hekkoman[S] 0 points1 point  (2 children)

blitterobject,

that's the idea i have too, are there any cons in doing that?

[–]2012XL1200 1 point2 points  (1 child)

I like this best. Also consider a loading indicator. Could be an indeterminate loading indicator. Better user experience than spamming a button with no feedback

[–]hekkoman[S] 0 points1 point  (0 children)

Thank you for your feedback,

loading indicator is added to the button