Search code examples
javascriptsweetalert2

sweetalert2 should redirecting to another html after clicking OK


Not showing alert, as well redirecting is not working

        //sweetalert2
        swal({
            title: "Success!",
            text: "Agent Created Successfully.",
            type: "success",
        }.then(function(){
            alert('here');
            window.location.href = "example.html";
        }));

Solution

  • Looks like your paren is misplaced:

        //sweetalert2
        swal({
            title: "Success!",
            text: "Agent Created Successfully.",
            type: "success",
        }).then(function(){
            alert('here');
            window.location.href = "example.html";
        });