Run an ajax script before submitting
<p>Good Day.</p>

<p>I'm having a problem with running a ajax call before a form submits. I'm just a newbie web developer so please bear with me.</p>

<p>My code is like this:</p>

<pre><code>$( function() {
 $('#formname' ).submit( function() {
  $.post( 'validation.php', $( this ).serialize(), function( data ) {
   if( data == 'something' ) return true;
   else return false;
  } );
 }
} );
</code></pre>

<p>This code is not working for me. Is there something wrong with the code or are there other ways to attain this.</p>

<p>Thanks in advance,</p>
