Good Day.
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.
My code is like this:
$( function() {
$('#formname' ).submit( function() {
$.post( 'validation.php', $( this ).serialize(), function( data ) {
if( data == 'something' ) return true;
else return false;
} );
}
} );
This code is not working for me. Is there something wrong with the code or are there other ways to attain this.
Thanks in advance,
you can define click event your submit button. and then when you click it, first do your post and then submit form.
html :
js: