title: Jquery form check returns true, but need to return false
body: <p>I am running this form check when the form is submitted:</p>
  
  <pre><code>if((formData[4].value == 1 || formData[4].value == 2) &amp;&amp; !formData[2].value) { 
      alert('Please fill out the key field');
      return false;
  } else {
      $.ajax({
          url: "/ajax/key_check.php",
          cache: false,
          data: "key=" + formData[4].value,
          dataType: "html",
          success: function(data) {
              if(data == 1) {
                  alert('Key already exists');
                  return false;
              }
          }
      });
  
      return true;
  }
  </code></pre>
  
  <p>The script works, it alerts key already exists if data does == 1, however the form still submits. I thought by returning false if data == 1 would stop the form from processing, however it continues and adds the key anyway and popups up key already exists message. How can I stop the form from submitting if data == 1? I tried even doing this:</p>
  
  <pre><code>if(data == 1) {
      alert('Key already exists');
      return false;
  } else {
      return true;
  }
  </code></pre>
  
  <p>Then removed the return true at the bottom of the script, but the same issue happens. Pop up comes up but the form still gets processed.</p>