title: Jquery submit a form via .submit() on AJAX success... how?
body: <p>I'm trying to send all form data to a script via AJAX by binding a click function to the submit button, setting it to return false so it doesn't submit the form yet. Once AJAX is done with success, I'd like to submit the form by doing: <code>$("#myform").submit();</code> But nothing happens.</p>
  
  <p>Everything works except for <code>$("#customOrderForm").submit();</code></p>
  
  <p>This is for a Paypal payment. Form data gets stored in a session, users go make they payment, return to the website once they successfully made the payment, form data gets send to customers and company via email.  </p>
  
  <pre><code>$("#submit").click(function () {
  
      var thedata = $("#customOrderForm").serialize();
  
      $.ajax({
          type: 'POST',
          url: 'buy-custom-session.php',
          cache: false,
          data: thedata,
          beforeSend: function () {
              $('#sessionholder').append('&lt;div class="loading"&gt;&lt;img src="loading.gif" alt="loading..." /&gt;&lt;/div&gt;');
          },
          success: function (data) {
              //$(".loading").detach();
              //$(".error").detach();
              //$('#sessionholder').append(data);
              $("#customOrderForm").submit();
          },
          error: function () {
              $('#sessionholder').append('&lt;p class="error"&gt;&lt;strong&gt;Oops!&lt;/strong&gt; Try that again in a few moments.&lt;/p&gt;');
          }
      });
  
      return false;
  
  });
  </code></pre>
  
  <p>HTML FORM</p>
  
  <pre><code>&lt;form id="customOrderForm" action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;
  
  &lt;!-- form fields etc --&gt;
  
  &lt;input type="image" name="submit" id="submit" src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>No ERRORS in Firebug.</p>
  
  <p>AJAX success executes. </p>
  
  <p>Cheers</p>