The above html automatically refreshes a page after 99 seconds. I tried to use it for a POST request to pre" /> The above html automatically refreshes a page after 99 seconds. I tried to use it for a POST request to pre" /> The above html automatically refreshes a page after 99 seconds. I tried to use it for a POST request to pre"/>

How to implement http-equiv/refresh with POST request?

1k Views Asked by At

<meta http-equiv="refresh" content="99" />

The above html automatically refreshes a page after 99 seconds. I tried to use it for a POST request to prevent a timeout error. However, it doesn't seem to work i.e., the meta tag has no effect whatsoever. Is there a way to do this in either html or a few lines of JavaScript? (I realize that a timeout error probably implies that I need to do some back-end refactoring. I'm looking for a quick-and-dirty solution here.) By the way, I want the solution to execute a GET request on the same URL, not another POST of the same data.

1

There are 1 best solutions below

1
pandichef On

Here's the solution:

document.onsubmit = () => {
    setTimeout(function(){
       location.reload();
    }, 99000);
}

In plain English, it says "reload the page via a GET request 99 seconds after making a submit/POST request".