Skip to content
Advertisement

Open bootstrap modal using Javascript in PHP

I’m trying to open bootstrap modal after login failed, I used the following code:

if (mysqli_num_rows($query) != 0)
{
    // Login successfully
}
else
{ 
    //Login failed
    echo '<script type="text/javascript"> $("#LoginFailed").modal("show")</script>';
} 

And I incloud jQuery 1.12.4 in HTML head

<script src="js/jquery-1.12.4.js"></script>

Nothing happen, The LoginFailed modal not showing up !!

I also trying the solution HERE but no luck.

Any help?

Advertisement

Answer

See exemple

I tried to tailor the exemple to yours. NOTE: In JSFiddle it will not be accurate since it only runs js css and HTML

You need to use

jQuery(document).ready(function (e) {
    // Your Modal
}
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement