I'm stuck with my auto refresh function in my web course assignment. I always put my code like this :
navigation.php :
<html>
<head>
.... ALL STYLE AND JS .....
</head>
<body>
<div class="menu">
...... ALL MY WEB MENU .......
</div>
index.php :
<?php
include "navigation.php";
function A(){
global $variable_functionA;
.... FUNCTION TO CALL API X BY cURL .....
}
function B(){
global $variable_functionB;
.... FUNCTION TO CALL API Y BY cURL .....
}
?>
<div class="container">
...... MY WEB CONTAINER ........
<div class="auto_refresh">
<?php
include "auto_refresh_data.php"; //Success when first load, failed to load style, js, etc at the second load
?>
</div>
</div>
<?php
include "footer.php";
?>
footer.php :
</body>
</html>
<scrpt>..... ALL MY JS SCRIPT.....</script>
My ajax code :
<script>
setInterval(function(){
$.ajax({
url:'auto_refresh_data.php'
}).done(
function(data){
$('.auto_refresh').html(data);
});
},5000);
</script>
auto_refresh_data.php :
<div class="style">
<?php
function A($variable1);
function B($variable2);
... OPERATION FOR GLOBAL VARIBLE RESULT FROM function A and function B ....
?>
</div>
I want to make an auto refresh data in the middle of my container. Then I made it in ajax like this : How do i auto refresh my div class content? . It failed because of some php variable, style, js, function, etc placed before the auto refresh div element. So the question is how to make it my data become auto refresh if my code design is like that?
Thankyou