why “return false;” or “event.preDefualt();” doesn’t work after $.post();
Firstly,I simply written a return false after
$(#id).submit(function(e){ return false;}// it works properly.But
when i call something via $.post('check-email.php',{parameter},function{data}) and i try to write return false after that $.post call.It doesn’t works and directly goes to next page.
here is my code:-
$(document).ready(function () { //newly added
$('#mysignupform').submit(function (event) {
return false;
or event.preDfault(); // only work here
var emailVal = $('#inputEmail').val(); // assuming this is a input text field
//alert(emailVal);
$.post('check-email.php', {
'email': emailVal
}, function (data) {
alert(data);
if (data == 'false') {
$("#mysignupform").submit(function (event) {
return false;
or event.preventDefault(); //both doesnt work here..why??
;
});
} else {
$("#mysingupform").submit(function () {
return false;
}); //retrun false doesnt work here..why??
}
});
});
});
I dont want to allow them to submit but still its happening. Please help me..!
Thanks in advance..
This should work: