I am trying to update the data inside the element every few seconds but the element completely disappears and I can't even see it
here is my code:
setInterval(function(){
$policeunits1 = $client->test->units;
$policeunit1 = $policeunits1->findOne(
['name' => 'police1']
);
$person1 = $policeunit1->id;
$status1 = $policeunit1->status;
if (!empty($status1)) $status1 = "<h2 style='color: yellow'>Code-7</h2>";
if (empty($status1)) $status1 = "<h2 style='color: white'>Code-9</h2>";
echo"<div class='dashboard'>
<div class='units'>
<div class='unitsheader'>
<div class='unitheadsep'></div>
<h>Units</h>
</div>";
setInterval(function(){
if (!empty($person1)) {
echo"<div class='unit1'>
<div class='unitseperator'></div>
<h1>$person1 : </h1>$status1
</div>";
}
},5000);
I tried to set interval and I expected that the element's data will keep on updating each 5 seconds