jquery : submitting a form twice
jquery
Solution
Try:
$('#form1').unbind('submit').submit();
Problem
I'm creating a registration form for a client for an event they're hosting. The basic user details are submitted to a third-party system (ie name, email etc.) but the rest of the fields need to be sent via email to the client. I need something like this to happen : - List item - user fills out form - jquery bvalidator checks the form for required fields - form is submitted (via ajax) to a seperate page where an email is sent to client - form is then submitted (regular POST method) to third-party system - on success user is passed back to a 'thank you' url. Here is the code I've tried using, but it gets caught in a loop repeatedly submitting itself to the 'email' page, and never submits to the external url. If I replace the `$('#form1').submit();` with an alert it submits only once to the email page and then displays the alert correctly. ``` var myvalidator = $('#form1').bValidator(optionsGrey); $('#form1').submit(function() { if (myvalidator.isValid()) { $.ajax({ data: $('#form1').serialize(), type: "POST", url: "email_send.asp", success: function() { $('#form1').submit(); } }); } return false; }); ``` Any suggestions as to how I can fix this?