I have an ajax code to save the form data in DB, all working properly, but my client need validate it with a qr code before to perform this action, so I added a modal to request the password with an input, but I don't know how to stop the ajax process until validate the password filled in the input...
Here the code:
$("#myForm").submit(function(event){
event.preventDefault();
$('#validateInput').modal('show'); //show modal with the input
$.ajax({
type: "POST",
url: "include/validation.php?ts=" + new Date().getTime(),
success: function( response ){
if(response == 1) {
$.ajax({
type:"POST",
url:"include/save.php?ts=" + new Date().getTime(),
dataType:"text",
data:$(this).serialize(),
beforeSend:function(){
$("#loading").show();
$("#result").empty();
$('#submit').attr("disabled", true);
},
success:function(response){
$("#loading").hide();
$("#result").append(response);
setTimeout(function(){
$('#submit').attr("disabled", false);
}, 3000);
},
error: function(response){
$("#loading").hide();
$("#result").append(response);
setTimeout(function(){
$('#submit').attr("disabled", false);
}, 3000);
}
});
} else {
swal({
type: "error",
title: "is not valid",
text: "try again...",
timer: 1000
});
}
},
error: function(response){
$("#loading").hide();
$("#result").append(response);
}
});
});