The function called by onLoad is called but stops before calling another function.
I'm sure this is what is happening because I added some debugging document.write() functions.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
function getTemp(){
document.write("3");//debugging
$.ajax( {
type: "GET",
url: "gettemp.php",
success:function(data){
document.write(data);
document.write("4"); //debugging
}
});
}
</script>
</head>
<body onload="onLoad();">
<script>
function onLoad(){
document.write("1"); //debugging
getTemp();
document.write("2"); //debugging
setInterval(function(){getTemp();}, 10000);
}
</script>
</body>
</html>
It outputs only "1", nothing else. Therefore, I am certain it stops before calling getTemp(). If necessary I will add the php file. As for the split scripts, if you put the onLoad() script in the head script you end up with nothing, not even the "1".
EDIT: Now it gets to "132", but it seems it isn't calling the PHP correctly.
PHP source:
<?php
getTemp();
function getTemp()
{
$filename = "temp";
$f = fopen($filename,"r");
$value = fgets($f);
$value = $value / 100;
echo $value;
}
?>