I know there are many entries about this topic but I dont get my code to work. I build a div container (this is the div I want to refresh every second) which includes 3 other div containers.
My code so far: index.php
<div id="ajax">
<div class="row d-flex align-items-center">
<div class="showPGF">
<?php
$controller->getEntries();
?>
</div>
</div>
<div class="row d-flex align-items-center">
<div class="showNGi_sample">
<?php
$controller->getUsers();
?>
</div>
</div>
<br>
<div class="row d-flex align-items-center">
<div class="showNGi_sample">
<?php
$controller->getPGFEntries();
?>
</div>
</div>
</div>
script.js
$(document).ready(function () {
function ajax(){
$('#ajax').load('index.php',function() {
$(this).unwrap();
});
}
ajax(); // This will run on page load
setInterval(function(){
ajax() // this will run after every 1 seconds
}, 1000);
}
I want to get the DIV with the "ajax" id to get reload every second. Because I want to get always the current Entries/Users from my database (execute the php call every second). But currently it dont refresh and I need to press F5 to get the new entries shown.