I have a php generated web page, which has several divs that are initially created using php includes.
<div id ="siteLeft" class ="site">
<div id="divGauges"><?php include('gauges.php');?></div>
<div id="divHistory"><?php include('history.php');?></div>
</div>
<div id="siteRight" class ="site">
<div id="divLymGauges"><?php include('gaugesLym.php');?></div>
<div id="divLymHistory"><?php include('historyLym.php');?></div>
</div>
These divs are then reloaded every 10 seconds, using an AJAX call, which is in a seperate scripts.js file:
function updateHistory(){
$('#divHistory').load('history.php'+"?ms=" + new Date().getTime());
$('#divLymHistory').load('historyLym.php'+"?ms=" + new Date().getTime());
}
setInterval( "updateHistory()", 10000 );
Within the history.php and historyLym.php, I have a function call, and the function is in another file called functions.php.
If I do:
include ('functions/functions.php');
within the index.php page, then the div's display nicely on initial load, but I get
Fatal error: Call to undefined function
displaying on the webpage after the AJAX call refreshes the div with the history.php and historyLym.php (obviously, as the include for the function file isn't in the div, which is the only bit that gets called).
So I tried putting the functions.php include into the divs that are loaded. If I do that, then on initial page load I get:
Fatal error: Cannot redeclare getForce()
which also makes sense, as on initial load the two divs both contain the include for functions.php.
Putting the include in only one of the divs results in the page loading fine (as it should do), but on the AJAX refresh of the divs, I get this error:
Fatal error: Call to undefined function getForce()
which again makes sense as the two divs are being refreshed independently by AJAX, and so only the div with the include for functions.php will be able to use the function.
So my questions is:
Where on earth can I put the include for functions.php so that the divs can use the functions.php functions on initial page load AND on individual seperate AJAX refreshes??