I have a custom WordPress template page that shows a table and when that table was last updated.
Using jQuery/AJAX, I am attempting to use setInterval() to check every second to see if the update time has changed and auto change the div id element showing the updated time.
I have tried reading tutorials. A lot of them show adding files to the /js/ folder, but my theme does not have that directory.
Looking at the different Wordpress plugins, I was only able to locate ones that showed Javascript across all pages, which isn't what I need.
I currently have a tag (see below) at the bottom of my custom page template. I verified that it loads in the page source.
<script type="application/javascript">
var update_time_function = window.setInterval(update_time, 1000);
function(update_time) {
jQuery.ajax({
url: 'https://website_url.com/last-update/'
dataType: 'json'
success: function(utf) {
jQuery('#update_time').text(utf[0].date_time);
}
})
};
</script>
The expected results should be the div element with the id 'update_time' should be updating, but it not happening. There are no errors in the network console.
The script file is showing in the page source.