In my form if you click Submit twice quickly enough I get two successful form ajax posts. How can I stop duplicate posts?
From what I can tell
- User clicks submit
- Ajax post sent
- User clicks submit (completed and valid form)
- Ajax post sent
- Ajax response received
- Page refreshed with empty (new empty form – requires values)
- Ajax response received
- Page refreshed with empty (new empty form – requires values)
The form is sent twice, I create two items.
There are similarly named questions but they relate to disabling validation or disabling ajax. Ajax, jquery validation and server side validation (Post-Redirect-Get in MVC) are working just fine for me.
Just to be clear I’m using jQuery Mobile’s Ajax navigation so I’m not writing any ajax.
This is the solution I have now is:
(Updated to work in webkit)
The delay is just in case something goes wrong. In reality the form should get replaced and the replacement will not be disabled.
Better suggestions welcome.