Contents
After you click the button in the modal the form should get submitted on the defined circumstances. So far so good. But my code for the button click inside the modal was inside the scope of the outer click handler. So after you opened up the modal twice the form was submitted twice.
Why does jQuery submit the Ajax form twice?
In case you are using some kind of validation (e.g jQuery Validation), the form is submitted twice because aside from $(‘#exportForm’).submit you write yourself, the validation plugin will also submit the form after it successfully validates all field.
What causes a POST request to be sent twice?
If you are using AngularJS, and lets say you make a controller called “HandleAjaxController” you could assign this ng-controller to a div, and then accidentally assign this same ng-controller to an inner div. This would cause the post request to be sent twice. So:
How to submit a form in CSS form submit?
? Above code will be applicable for both the forms as both are with the class name “validateForm”. submit the particular form which you want. I like… Just out of curiosity, why bother defining your functions as “var foo = function () { }” in this usecase?
How to redirect users after submit button click?
It is better than using window.location.href =, because replace () does not put the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco. If you want to simulate someone clicking on a link, use location.href. If you want to simulate an HTTP redirect, use location.replace.
How to prevent double clicking on a form?
So when the form is submitted – either by clicking on the submit button or pressing Enter in a text input field – the submit button will be disabled to prevent double-clicking.
A second click on the Submit button before the form has finished submitting will generate an alert message, and also disable the button preventing subsequent clicks. The difference from previous examples is the alert when the button is being disabled.