In your load.php at the end:
echo json_encode($loadout);
In index.html
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
//Calling function
repeatAjax();
function repeatAjax(){
jQuery.ajax({
type: "POST",
url: 'load.php',
dataType: 'json',
success: function(resp) {
jQuery('#out1').html(resp[0]);
jQuery('#out2').html(resp[1]);
jQuery('#out3').html(resp[2]);
},
complete: function() {
setTimeout(repeatAjax,1000); //After completion of request, time to redo it after a second
}
});
}
</script>
5
solved Ajax code the auto refresh a php file and updates it’s vaules [closed]