Why doesn't jQuery submit this form?

I am trying to submit a form with jQuery, and I have to miss something small, because I cannot get this to work, and from everything that I see, it should work fine.

What happened to 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 javascript:

    $("#subthis").click(function() {
        $('#editthis').submit(); // An alert box works, so I know this is triggering
    });

As indicated in the code, the warning window works if I press the submit button, but when I use the jQuery send function, nothing happens. What am I missing ???

+3
source share
2 answers

I see two possible problems.

1) There tableare tags in the tags form. Although this is probably not the main cause of your problem, this is invalid HTML.

2) "" name . , JavaScript. - , "submit", id.

+4

jQuery . , , .

, . .

<form id="edit_this" action="page.php" method="POST">
    <label>Name <input type="text" name="name"></label>
    <label>Company <input type="text" name="company"></label>
    <a href="?action=browse">Cancel</a>
    <button type="submit">Update</button>
</form>

layout'd .

- jQuery, onsubmit, .


, JavaScript. submit .

+5

All Articles