How to achieve page refresh in JavaScript?
You can use the location.reload() method to refresh the page.
location.reload();
This method will reload the current page and resend the request. If there are unsaved data or forms on the page, the browser will prompt the user to confirm whether to reload the page.
If you only want to reload a specific part of the page, you can use fetch or XMLHttpRequest to send asynchronous requests and then replace the specified element with the returned data.
fetch(url)
.then(response => response.text())
.then(data => {
document.getElementById('targetElementId').innerHTML = data;
});
Please be cautious when reloading the page as it will result in losing all the current data and status of the page.