Recursive jQuery submit function doesn't submit the form?

$("#simplr-reg").submit() That says "call the submit method on the jQuery selection". You have a jQuery submit handler bound to the selection. Since you have triggered the event on the jQuery selection, the jQuery handler is also triggered If you trigger the event on the native DOM form object ( this within the submit handler), the jQuery handler will not be triggered, so you won't go round in circles.

Call the form. Submit method: this.submit().

$("#simplr-reg").submit(); That says "call the submit method on the jQuery selection". You have a jQuery submit handler bound to the selection. Since you have triggered the event on the jQuery selection, the jQuery handler is also triggered.

If you trigger the event on the native DOM form object (this within the submit handler), the jQuery handler will not be triggered, so you won't go round in circles. Call the form. Submit method: this.submit().

Lonesomeday, thanks. It seems to be working with the code I've shown in the question. But in my full code the first submit function calls another function which at its end I should call the second submit.

But it doesn't recognize the 'this' operator there. What can I do? – Ash May 16 at 21:30 @Ash $('#simplr-reg').

Get(0).submit(); get retrieves the native DOM element, so you can call the native submit method on it. – lonesomeday May 16 at 21:33 @lonesomeday, it still doesn't submit. I've placed the script here, and would be greatful if you can take a look.

The other fuction, called "codeAddress", is in yellow but no need to go through it all. Just its end where I call the submit again. – Ash May 16 at 21:55 @Ash Do you get any errors?

That looks like it should work, but I'm not familiar with the API you're using. – lonesomeday May 16 at 21:59 @lonesomeday, I've stripped the function to include only the call to the submit function. You can take another look at the code here.

But it still won't submit. – Ash May 16 at 22:19.

ETA: be sure to 'return false' on your non-submit case. $("#simplr-reg-submit"). Click(function() { alert("1st iteration"); $("#simplr-reg").submit(); return false; }).

1 It would probably be better for him to add a click event for a button (anything that doesn't automatically submit), and then simply call the form submission event once the other function is done. No need to make it "recursive" – jacobangel May 16 at 20:28 True enough, but if everything's already created (i.e. Autogenerated form), click w/ return false is the way to go.

– Brian Wolfe May 16 at 20:34 jsfiddle. Net/fcgJV – kei May 16 at 20:38 @Brian, thanks for the quick reply. Is returning false enough?

Shouldn't there also be event.preventDefault();? Also, is my syntax correct if the form's name is simplr-reg and the button's name is submit-reg : $("#simplr-reg. Submit-reg").

Click(function(event)? – Ash May 16 at 20:49 2 @Ash @Brian In jQuery handlers, return false is equivalent to calling both e.preventDefault() and e.stopPropagation(). – no.good.at.

Coding May 16 at 20:54.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions