I want to show an alert for 5 seconds on click of a button but the button is of type="submit" with method="post".So this works but only for few nanoseconds because after that page reloads and it doesn't count and show the remaining seconds of alert to show
Here is my alert code
<div class="alert alert-danger balance" id="inbalance" role="alert" >
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="alert-heading">Order <b>Unsuccessfull</b></h4>
<p>Hey,Your order for car is Unsuccessful due to <b>insufficient balance </b> </p>
<hr>
</div>
Here is my code to show alert
function myAlertBottom(){
$("#inbalance").show();
setTimeout(function(){
$("#inbalance").hide();
}, 5000);
And button code
<button type="submit" class="btn btn-success btn-lg buy" onclick="myAlertBottom()" style="width:50%;" th:disabled="${1 eq g2}">BUY</button>
Form code in HTML
<form action="" th:action="@{/g2form}" th:object= "${game2data}"
method="post">
</form>