var myVar;
var tone = new Audio('../assets/sound/signal100.ogg');
var signal;
signal = $.get('otherPage.html');
function myFunction() {
myVar = setInterval(signalCheck, 1000);
}
function signalCheck() {
var signal = <?php $query = $db->query("SELECT * FROM `servers` WHERE `id` = '1'");
$data = $query->fetch_array(); echo $data['radioStatus']; ?>;
if(signal == 100) {
document.getElementById("signal100").innerHTML = '<div class="alert alert- danger" role="alert" style="text-align: center; height: 50px;"><p><b>Function Triggered! <a href="#" data- toggle="modal" data-target="#liftSignal">Lift signal</a></p></div>';
tone.play();
setInterval(myFunction, 1000);
} else {
document.getElementById("signal").innerHTML = "";
tone.stop();
}
}
window.onload = myFunction();
This is what I am using currently. It all works fine, only I have to reload the page; something I want to prevent. I want to have the script check the query and if the value I want to see changed has changed. When it changes to 100, it should play my sound and pop up my banner. If I set my database valuable to 100 and reload the page, it goes fine, only when I set it back to 0 or whatever value, I have to reload the page to see the effect.
What am I doing wrong?