Use custom Alert in javascript

Asked

Viewed 127 times

1

I’m trying to use something other than the standard javascript alert and apparently changing the syntax doesn’t work. For example, this code works.

$mysqlInsert = mysqli_query($conexao,$sqlInsert);
            if (!mysqlInsert) {
                die('Error: ' . mysqli_error()); 
            }
            else {
                echo '<script>window.alert("Produto adicionado com sucesso!");
                        window.location.href="main.php";</script>';
                }
}

But not this one (the library is being called correctly):

$mysqlInsert = mysqli_query($conexao,$sqlInsert);
            if (!mysqlInsert) {
                die('Error: ' . mysqli_error()); 
            }
            else {
                echo '<script>swal("Produto adicionado com sucesso!");
                        window.location.href="main.php";</script>';
                }
}

I could see that only when I use onclick, on a button for example, that I can call custom Alert. Can anyone explain to me why?

  • Related: http://answall.com/q/66706/129

  • You managed to resolve by consulting the link posted by @Sergio?

  • No, I had to do it by javascript anyway

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.