Hi all,
I have a small silly issue which i'm embarrassed I cant solve...
I have a function which loops every second to see if a status has changed.
When the status changes, I want it to call a phonegap 'beep' notification.
The issue is it keeps calling the beep sound every second due to the constant iteration of the function.
I thought the best solution was to declare a global variable to 'false' and change it to true once first iteration is passed, but it didnt work.
Can anybody guide me on this?
Thanks all.
function checkResponseStatus(){
$.getJSON("requestrespond.php",
function(data)
{
//variables from output object
var id = parseInt((data.id),10);
var respond_date = (data.respond_date);
var respond_status = parseInt((data.respond_status),10);
var respond_time = (data.respond_time);
if (respond_status == 1) { //request has been made
document.getElementById("responseStatus").disabled = false;
document.getElementById("responseStatus").innerHTML = "Request Sent on "+ respond_date + " <br /> Time: " + respond_time + "<br /> " + "Click Here To Respond";
navigator.notification.beep(1);
}
}
else{
document.getElementById("responseStatus").disabled = true;
}
});
}