I could not do this with any of the default swal (sweatAlert) functions, so I forced jquery to use the Ok button class, the validation element in chrome, did something like this:
<script> sweetAlert({ title:'Warning!', text: 'Invalid user or password!', type:'warning' },function(isConfirm){ alert('ok'); }); $('.swal2-confirm').click(function(){ window.location.href = 'index.php'; }); </script>
The "Ok" function in the (isConfirm) function was just a test to see if it would fall into this function, if so I had to redirect from there, but I wasn’t ...
So, I used jQuery to determine if the "OK" swal button was pressed, getting its class: ".swal2-confirm", after which I could redirect with success ...
Hope this helps all of you!
PS: I use php echo to run the script, I do not need to leave php to run it, just use single quotes, and you're done!
source share