I'm using sweet alert for my website but would like to know how I could execute a php script which is in another page once the user has confirmed his action.
Here is a sample of the code :
HTML
<a href="#"><p onclick="go()">Approve/Refuse</p></a>
JS
function go() {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Validate user',
cancelButtonText: 'Refuse request',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger m-l-10',
buttonsStyling: false
}).then(function() {
swal(
'User validated!',
'The user has been notified.',
'success',
)
}, function(dismiss) {
// dismiss can be 'cancel', 'overlay',
// 'close', and 'timer'
if (dismiss === 'cancel') {
swal(
'User refused',
'The user has been notified.',
'error'
)
}
})
};