As it says in the title I have a call ajax that together I use it with the jquery validator, the problem is when I use the function that comes with the validator that is called isDefaultPrevented () the validation works perfectly without problems except that nothing is activated within the success of the ajax, inside there I have to call a modal and also does not even trigger the console log, if I remove the isDefaultPrevented () and only use the preventDefault, it triggers the verification of the form and detects the errors but it carries out the call ajax and there if the manners work well. Will there be any other alternative? Thank you very much.
$('#candidateForm').validator().on('submit', function(e) {
if (e.isDefaultPrevented()) {
// handle the invalid form...
} else {
var dataString = $('#candidateForm').serialize();
$.ajax({
type: "POST",
url: "work/php/onlineApplication/addNewCandidate.php",
data: dataString,
dataType: "json",
success: function(result) {
console.log(result['data'].status);
if (result['data'].status == 'error') {
$("#bodyMsgModal").html(result['data'].message);
$("#addUserModal").modal('show');
$(result['data'].Field).focus();
}
if (result['data'].status == 'success') {
$("#bodyMsgModalSuccess").html(result['data'].message);
$("#addUserModalSuccess").modal('show');
$('#candidateForm')[0].reset();
}
}
});
}
});