I have a form, and when I submit him I execute multiple script. Here is my code:
$(\"#RequestCreateForm\").submit(function (e) {
if ($(\"#RequestCreateForm\"
When you call $("#RequestCreateForm").submit()
, the script will just run through the event handler again, and cause an infinite loop (as Koen pointed out in a comment on the accepted answer). So, you need to remove the event handler before submitting:
$("#RequestCreateForm").on('submit', function (e) {
e.preventDefault();
// do some stuff, and if it's okay:
$(this).off('submit').submit();
});
The last line needs to be in a conditional statement, otherwise it'll just always happen, and negate your e.preventDefault();
at the top.