php - Sweet Alert confirmation before submit form using Ajax
Get the solution ↓↓↓Solution:
update this
<div class="modal-footer">
<input type="button" class="btn btn-default" data-dismiss="modal" value='Close'>
<input type="button" class="btn btn-primary" id="btn_upload" value='Submit' />
</div>
$(document).ready(function(){
$('#addInputFile').on('click', function(){
$('#myModal').modal('show');
});
$('#btn_upload').on('click', function(){
Swal.fire({
title: 'Are you sure?',
text: "The data will input",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Add',
cancelButtonText: 'Cancel'
}).then((result) => { alert('resolved');
if (result.value) {alert('submitting');
$.ajax({
url:'myfile.php',
type:"post",
data:new FormData(this),
processData:false,
contentType:false,
cache:false,
async:false,
success: function(data){
alert("Input Form Success.");
},
failure:function(d){
alert("Error")
alert(d)
}
});
}
})
});
});
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: filter_sanitize_string deprecated
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.