I have implemented a comment system using ajax that is functioning well. I am looking to incorporate an ajax/js code to automatically refresh my "time ago" div every 5 seconds so that the time updates while users are viewing the same post.
Important note:
I am specifically seeking a code that will send a request to the server to refresh the contents of a specific div after a set time interval, without reloading the entire page or div.
I am new to working with js/ajax and have attempted the following code which has not successfully updated the content as desired:
$(document).ready(function () {
setInterval(function () {
$("#showtimeago").load();
}, 1000);
});
The desired outcome is:
<div class="p_timeAgo" id="showtimeago"> <?php time_stamp($timePost);?></div>
Can anyone offer assistance in resolving this issue?