Vitaly Batonov
Vitaly Batonov

Reputation: 1132

submit form event doesn't work! Why?

I can't give link to project, therefore put example on jsfiddle.

In my project this example work,

But this not!

Help please, i want send form by SUBMIT form event!

UPDATE 1: I don't know why it not work. Until i write like this :\

$('.container input[type="submit"]').click();

UPDATE 2: Found the problem: I'm insert second form via jQuery ajax. receiving data contain HTML and style/script for inserting HTML. It script adds TinyMce to textarea element. Likely jQuery \ TinyMce deleted submit event handler.

Upvotes: 0

Views: 1608

Answers (2)

Alejandro Martin
Alejandro Martin

Reputation: 5877

Check if the URL in the action attribute is a correct one (I mean, there is something at this URL). I have noted that when using jQuery to trigger the form submit, if the server returns an error (i.e. Http 404), the request dies silently, without any error or notification to the browser.

But I have checked your code setting the form's action to another URL and it worked OK.

Upvotes: 0

Shef
Shef

Reputation: 45589

You can't do it like that. You can do it like this though,

<div class="container">
    <form action="/K4VG2/2/show">
        <input type="text" name="field1">
        <input type="text" name="field2">
        <input type="text" name="field3">
        <input type="submit" value="Send">
    </form>
    <button type="button">go</button>
</div>

Then, on the server side, where you process the form, you can check which fields were filled and which ones were empty. So, you just use the ones which had content.

Upvotes: 1

Related Questions