rails: ajax avoid multiple form submit

692 Views Asked by At

I have an submit button and need to ensure that is only pressed/submit one time until the AJAX request is finished. The Javascript solutions are not safe in case of noScript. Is there a propper way to do that in Rails?

1

There are 1 best solutions below

3
On

Simplest solution would be generating a token and placing it as a hidden form field. When the form is submitted, go to the database and mark the token as used, if another form submit sends the same token again, it's a double submit and you should do whatever you would like to do with it.