title: Trigger event.preventDefault(); only if condition is met - Jquery / javascript
body: <p>All I want to do is check if some of the values in a form (name, email) are not already in the database before I submit it.</p>
  
  <p>I have a php script that works well and returns strings that corresponds to the issue, or "no output" in case there's nothing wrong.</p>
  
  <p>The only problem I have is with the event.preventDefault(), which should only be called if the php script returns something other than "no output".
  It doesn't work when it's within the get() call and I tried using an if statement, whether or not the error div is empty or not, but it didn't work either.</p>
  
  <pre><code>$(document).ready(function() {
  $( "#signupForm" ).submit(function( event ) {
      $.get( "signupchecker.php", { name: $('#name').val(), email: $('#email').val() } ).done(function ( data ) {
          if( data != "no output" ) {
              $( "#error" ).text( data );
          }
      });
      event.preventDefault();
  });
  </code></pre>
  
  <p>});</p>
  
  <p>thanks!</p>