My Ajax method looks like this
$.post(url,{
ajax_call:\"putDonation\",
addresse:addresse,
phone:phone,
email
This is my code use in my site.
swal({
title: 'Are you sure?',
text: "Are you sure that you want to cancel this order?",
showCancelButton: true,
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
showLoaderOnConfirm: true,
preConfirm: function () {
return new Promise(function (resolve, reject) {
$.ajax({
success: function(response) {
resolve(response)
},
error: function(a, b, c){
reject("error message")
}
})
})
},
allowOutsideClick: false
}).then(function (response) {
swal({
title: 'Success',
type: 'success',
html: 'Thank you
',
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'Close!',
allowOutsideClick: false
}).then(function () {
window.location = '/';
})
})
In
preConfirm: function () { return new Promise(function (resolve, reject) {}) }
You must call
resolve(response)
or
reject()
after ajax responses.