Trouble With jQuery form.submit()

Argh… I run into an issue with jQuery submitting a form using submit() that took me few hours to resolve. I had a problem submitting a form using a call like $("#myForm").submit(). What was driving me nuts was that event listener for “submit” was triggered (no, I didn’t use preventDefault()) but at the end nothing happened - my form was not submitted.

So, after pulling my hear I’ve found that the problem was my submit button that was named, well… also “submit”:

1

Simple rename of the button fixed the issue:

1

In short, submit button name matters!

On a second thought, maybe this is not related with jQuery but rather with JavaScript or browser behaviour. However, I spent enought time on this already so I’ll leave verification of this for an exercise.

Comments