I am having issues with (I believe) setInterval on a div.
The setInterval loads my "panic.php" page which shows if there is a row in the panic table. I need to continuously reload the div until the row has been deleted and I thought setInterval was my best option...
jQuery Code (js/panic.js)
setInterval(function () {
$("#panicInfo").load("process/GET/panic.php");
}, 1000);
PHP code (process/GET/panic.php)
$stmt = $conn->prepare("SELECT `rpname`, `location` FROM panic");
$stmt->execute();
$stmt->bind_result($panicrpname, $paniclocation);
$stmt->store_result();
$stmt->fetch();
if ($stmt->num_rows == 1) {
echo '
<div class="row mt-5 justify-content-center">
<div class="col-md-10">
<div class="alert alert-panic">
<div class="text-center display-6 mb-3">ALERT</div>
<div class="text-center mb-3">
Panic button has been pressed by ' . $panicrpname . '.
</div>
<div class="text-center mb-3">
Please respond to <b>' . $paniclocation . '</b> immediately.
</div>
<div class="mt-3 text-center">
<button type="button" class="btn btn-outline-light" id="clearPanicBtn">
Respond & Clear
</button>
</div>
</div>
</div>
</div>
</div>
';
}
$stmt->close();
My issue is I cannot click the button whatsoever.
I've tried to get a button outside of the div to clear the panic alert, but it is more code to add to continuously check if a row exists and if not, don't show the button to clear..