Complete rewrite of my question
The task I am trying to do is update the display of five variable without reloading the whole page.
I have a php file (check_conf_update.php) which runs a query that produces data and I am scripting it into JSON. In the PHP file that runs the query I have at the end:
echo json_encode($record);
The JSON result looks like this:
[{"ClientName":"Another","RoomFromDateTime":"2016-02-25 01:00:00","RoomToDateTime":"2016-03-13 23:00:00","ClientImageName":"anothernew.png","DisplayText":"System Testing"}]
I now need to use the data on a page called "template.php). How can I read the data from the Json result and assign each of the result elements in variables I can use on my "template.php" page. I need the Json script to run every x seconds so the display is always shows up todate information.
I have five php variables:
$CientName
$ImageName
$DisplayText
$FromTime
$ToTime
which I use on my web page to display the data on the same page as the script below.
$(document).ready(function() {
function runupdate() {
$.ajax({
url: 'check_conf_update.php',
type: 'GET',
data: 'record',
dataType: 'json',
success: function(data){
// not sure what I need to do here
}
});
};
// run it initially
runupdate();
// run it every 30 seconds
setInterval(runupdate, 30 * 1000);
});
Sorry if have confused anyone, and it looks like I did.
Can anyone help. Many thanks in advance for your time.
Regards