I'm using SweetAlert2 and want to redirect the user to a different page, BUT after the success alert and the user clicks OK.
this one:
swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
closeOnConfirm: false
},
function() {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
);
});
like this:
function deleteEvent(id)
{
swal({
title: 'Are you sure?',
text: 'You will not be able to recover this event!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
closeOnConfirm: false
}).then(function() {
swal(
'Deleted!',
'Your event has been deleted.',
'success'
);
$.ajax({
url: '/events/'+id,
type: "DELETE",
data:{ _token: "{{csrf_token()}}" },
success: function() {
location.href = '/events';
}
});
});
}
But when the user clicks the confirm button to delete....this popup
goes right away because of my redirect and the user doesn't even get the chance to click the OK button...
How can i make the redirect AFTER the user clicks the OK on this image?