Trouble with jQuery form.submit()

by radomir on March 17, 2010

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”:

<input name="submit" type="submit" value="Report" />

Simple rename of the button fixed the issue:

<input name="report" type="submit" value="Report"  />

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.

Using Java? Speed-up bug fixing and improve customer satisfaction using LogDigger to create detailed error reports and notifications for your web application

Leave a Comment

Previous post:

Next post: