Why won't jQuery submit this form?

forms, jquery, php, submit

Solution

I see two possible problems.

1) You have `form` tags inside `table` tags. While this probably isn't the root cause of your problem, it's not valid HTML.

2) You've used "submit" as the `name` of your submit button. This should be avoided because your object will collide with JavaScript reserved words. Use something other than "submit" like you've done with the `id` attribute.

Problem

I am trying to submit a form with jQuery and I must be missing something small, because I can't get this to work, and from everything I see it should work fine. What's wrong with this? ``` <table class="newrecord"><form id="editthis" action="page.php" method="post"> <tr><td class="left">Name:</td><td><input type="text" name="name" id="name" /></td></tr> <tr><td class="left">Company:</td><td><input type="text" name="company" /></td></tr> <tr><td class="left"><a href="?action=browse">Cancel</a></td><td><input type="button" name="submit" class="subbut" id="subthis" value="Update" /></td></tr> </form></table> ``` And the javascript: ``` $("#subthis").click(function() { $('#editthis').submit(); // An alert box works, so I know this is triggering }); ``` As mentioned in the code, an alert box works if I click the submit button, but when I use the jQuery submit function, nothing happens. What am I missing???

Original source

Related problems