How To Auto Refresh Table On View Page

Dear All,Refer to this topic, https://discourse.hkvstore.com/t/auto-refresh-page/486/1 try to put the code on Client Scripts → Table-Specific → ViewPage → StartupScript
Here my code :

loadjs.ready("load", function() {
// check for updates every 3 seconds
function refreshTable() {
	tableRefresh = setInterval(function() {
		$('table.ew-table > tbody').load(location.href + ' table.ew-table > tbody tr', function() {
		$(this).find('tr:even').removeClass('ew-table-alt-row').addClass('ew-table-row');
		$(this).find('tr:odd').removeClass('ew-table-row').addClass('ew-table-alt-row');
		});
	}, 3000); // Change this value as appropriate to set the refresh period ... 1000 = 1 second
}
refreshTable();
});

But nothing happend, the table on view page won’t refresh.
Is there something wrong with my code? (version 2020)

That post was about refreshing the List page, not View page.

what should i do for refreshing the view page, without reload whole page?

You may use the same idea as the original topic, see Loading Page Fragments.

I’m trying to change my code from this :
$(‘table.ew-table > tbody’).load(location.href + ’ table.ew-table > tbody tr’to this :
$(‘table.ew-view-table > tbody’).load(location.href + ’ table.ew-view-table > tbody tr’So, this is the complete code :
function refreshTable() {
tableRefresh = setInterval(function() {
$(‘table.ew-view-table > tbody’).load(location.href + ’ table.ew-view-table > tbody tr’, function() {
$(this).find(‘tr:even’).removeClass(‘ew-table-alt-row’).addClass(‘ew-table-row’);
$(this).find(‘tr:odd’).removeClass(‘ew-table-row’).addClass(‘ew-table-alt-row’);
});
}, 3000); // Change this value as appropriate to set the refresh period … 1000 = 1 second
refreshTable();
});The time interval work, but my table has gone and left blank view.
Any advice I will thank you