Reputation: 687
The below Javascript
function still fails in pointing to the relevant URL
, although I cannot see any abnomaly. Hence a puzzlement leading to this post.
if(msg) {
if (msg.provider == "sweetAlert") {
swal.fire({
title: msg.title,
text: msg.text,
icon: msg.icon,
timer: 5000,
confirmButtonColor: "black",
BorderColor: "white"
}, function(){
var url ='@Url.Action("Action","Controller")';
window.location.href = url;
});
}
Thus, any relevant feedback would highly be appreciated.
Thanks in advance. Best
Upvotes: 1
Views: 3286
Reputation: 4208
Swal.fire({
title: 'Some title',
showCancelButton: true,
confirmButtonText: 'Go to Google',
}).then((result) => {
if (result.value) {
var url = 'https://www.google.co.uk/';
window.location = url;
}
});
Use then
function to handle callback. If result.value
is true
indicates user click on Okay button.
$(document).ready(function () {
Swal.fire({
title: 'Some title',
showCancelButton: true,
confirmButtonText: 'Go to Google',
}).then((result) => {
if (result.value) {
alert('user click on Okay button');
var url = 'https://www.google.co.uk/';
window.location = url;
}
else {
alert('user click on Cancel button');
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
Upvotes: 1