To refresh a page without reloading, you have to load the contents of the page through ajax. You could do this as follows:
index.php
<html>
<head>
<script type="text/javascript">
$(document).on('ready', function(){
setInterval(function() {
$.ajax({
type: "GET",
url: "ajax_refresh.php",
success: function(result) {
$('body').html($result);
}
});
}, 3000);
});
</script>
</head>
<body>
<div class="header">
Header of website here
</div>
<div class="content">
Content here
</div>
<div class="footer">
Footer here
</div>
</body>
</html>
ajax_refresh.php
<div class="header">
Header of website here
</div>
<div class="content">
Content here
</div>
<div class="footer">
Footer here
</div>
In the above example the ‘url’ parameter should be a PHP file that only returns the body of the page you want to refresh. For this example to work, you should include jQuery.
Good luck
Edit
To explain this a little more. You will need a second file that looks exactly te same as your index file. Except that in this second file you do not have html, head or body tags. The content of the second file will be loaded into the first file without refreshing. This is the concept of AJAX.
For further reading:
– Introduction to AJAX – W3Schools
5
solved Auto refresh PHP script backend [closed]