I looked around for a while but I didn't find the information I'm looking for.
I have the following question. I've my code that using the getstatus function executes a settimeout loop every 10 seconds. In this loop the ajax takes some variable from a php page and set some variables values. My problem is with the value property of the g object.
I starts to define the g object and then its property g.value to be global.
In the gestatus function I get the value I want from the ajax call (TA_1) and then the setTimeout function starts in which I update the g.value to the new TA_1. But in this way it doesn't seem to update the property value in the g object. I found the way to put the entire object definition after the setTimeout function, but in this way it creates new object at every loop. There is a way to refresh an object property inside a setTimeout loop?
Thanks to everybody.
Cheers
var g = new JustGage({
id: "TA1",
value: 0,
min: 0,
max: 1000,
width: 100,
height: 100,
title: "Tsys A 1",
});
g.value = {};
$(function() {
getStatus();
});
function getStatus() {
var TA_1 = {};
$.ajax({
url: "getstatus2.php",
async: false,
dataType: 'json',
success: function(data) {
TA_1 = data.TsysA1;
}
});
setTimeout("getStatus()",10000);
g["value"] = TA_1;
}