I know this code below will force a page to reload every 5 seconds and display its contents in the assigned div
$(document).ready(function() {
setInterval(function () {
$('#comment_display').load('comments.php')
}, 5000);
});
But I want to know if it's possible to replace the page URL with a div so that it force the div to reload every 5 seconds without reloading the page for example:
<div id="my_div" style="display:none;">
<!-- run the database query to collect data from database and echo it out -->
</div>
<script>
$(document).ready(function() {
setInterval(function () {
$('#comment_display').load($('#my_div'))
}, 5000);
});
</script>