I have my main file which is displaying some graphs etc - this works fine.
Now I came up with the idea to display some temperatures in a more timely fashion - as in - refresh it every like 2 - 10s.
Ive added a little php script which explodes the sensor info and formats it, this works fine by itself:
$sensor1 = file_get_contents('sensor1');
$sensorinfo1 = explode ("t=", $sensor1);
$sensor2 = file_get_contents('sensor2');
$sensorinfo2 = explode ("t=", $sensor2);
printf("Aktuelle Temperaturen: Sensor1: %s Sensor2: %s", $sensorinfo1[1] / 1000,$sensorinfo2[1] / 1000);
My knowledge about Javascript, Ajax and jQuery is rather ... well. Lets not talk about it. I came up with the following things for that part after searching around for a while already (it doesnt work, and I do not know why):
setInterval(function () {
$('#curtemp').load('grabsensorinfo.php', function () {
}, 5000);
});
and the div element:
<div class="curtemp">
</div>
So what I'd like to have is the div element being updated every X seconds.. Anyone got an idea where I go wrong?
This is what I got to now - not working still:
var tempUpdate=function() {
$('#curtemp').load('grabsensorinfo.php')
};
setInterval(tempUpdate,5000);