I need to update notification if there's any change in database without slowing down the whole website, so I done this:
HTML:
<div id="myid"></div>
Back-end Request (using Laravel):
$db_data = App\Marks::where(["subject_id" => 2])->pluck("marks")->first();
return view("myView", compact('db_data));
jQuey Request Every Second:
setInterval(function() {
$('#myid').load(location.href + " #myid");
console.log("refreshed");
}, 1000);
The main problem here is it slows down the whole website, by sending requests in each second.
Someone recommended me to use Sockets but I'm not good at JavaScript, so I need a simple and versatile solution.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire