I am trying to update a div’s content automatically with this script:
function update() {
$.get("authentication/notifications.php", function() {
$(".notificationBox").html();
window.setTimeout(update, 10000);
});
}
But for some reason it’s not working. Nothing happens on the page.
notifications.php has to get some data from the database. And I know it’s getting it, cus on a normal update of the page it’s showing up.
notificationsBox is inside of the notifications.php and is just a normal div in a foreach() loop.
My notifications.php looks like this:
<?$notifications = $db->notifications();
foreach($notifications as $notifications):?>
<div class='notificationBox'><?=$notifications['pushCommentsContent'];?></div>
<?endforeach;?>
I want the DIV to be outputted on update, or to be added to the existing.
If you use load, it can do the sorting for you:
Here it will search otifications.php for a element with class notificationBox and insert that into a element on your current page with the class notificationBox.
So it’s important that the class of the element you want to update has the class 🙂
You are not inserting the contet you get, into anything 🙂