what is wrong with my sweetalert 1, it is not firi...
# javascript
s
what is wrong with my sweetalert 1, it is not firing the confirmation
Copy code
function showMessage() {
    swal({
        title: "",
        html: 'This will trigger some updates</b>',
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "##EF5350",
        confirmButtonText: "Yes, Proceed",
        cancelButtonText: "Cancel",
        reverseButtons: true
    },function(isConfirmed) {
        alert(isConfirmed)
        if (isConfirmed) {
            alert($(".openStandings").attr('data-href'));
            $.ajax({
                type: "POST",
                url: $(".openStandings").attr('data-href'),
                success: function(data) {
                alert(data);
                if (data.toLowerCase().indexOf("error") >= 0) {
                    swal({
                        title: "Oops",
                        text: data,
                        type: "error",
                        showCancelButton: false,
                        confirmButtonColor: "##EF5350",
                        confirmButtonText: "OK",
                        closeOnConfirm: true
                    });
                } else {
                    swal({
                        title: "Great",
                        text: data,
                        type: "success",
                        showCancelButton: false,
                        confirmButtonColor: "##EF5350",
                        confirmButtonText: "OK",
                        closeOnConfirm: true
                    });
                }
            }
            })
        }
    })
}
m
search google for "alert vs confirm vs prompt"
m
I have never used swal, but things that could be helpful to us. • Do you have a recreation in like JSFiddle? • What is the error message that is being produced? The best demo is reducing all outside dependencies. Looking at the api documents for swal the way it handles callback is with promises. Here is a simplified demo of it https://jsfiddle.net/zgw1xfse/3/
s
it seems i have to use promise