title: Submit a form from inside an ajax success function that checks the values
body: <p>I've seen about 20 or more posts on the subject, but they either don't make sense to me or slightly different.</p>
  
  <p>It's a pretty simple scenario as well.  I have a form, when it submits, I do an ajax call to see if the email is not taken already by another user.  If not taken I want to submit the form, if it is, don't submit form.</p>
  
  <p>Here's the HTML</p>
  
  <pre><code>&lt;form id='greatForm' action='godothat.php' method='post'&gt;
  &lt;input type='submit' id='email'&gt;
  &lt;button&gt;Send&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The JS</p>
  
  <pre><code>$('#greatForm').submit(function(){
  
  
          // GET THE VARS
          var email = $('#email').val();
  
  
           $.ajax({ 
              data: { 'field1' : email  },
              type: 'GET', 
              dataType: 'json',
              url: 'url.php',
              beforeSend : function(){   },
              success: function(answer){   
                  if(answer.error === false){
                           // Submit this form without doing the ajax call again
                  } 
                  if(answer.error === true){
                      // Not ok, don't submit this form
                  }
              }
          });                               
  
          return false;   
      });
  </code></pre>
  
  <p>Thanks for any help.</p>
  
  <p>** UPDATE **
  Maybe I didn't phrase it right.  What I mean is if the "answer.error === false" is true then the submit function should return true.  </p>
  
  <p>So on AJAX complete, if answer.error is false, the submit should be true and vice versa...</p>
  
  <p>Does that make more sense?</p>