0

<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.

pandichef
  • 706
  • 9
  • 11
  • how will a other GET fix your timeout? – flaxon Nov 10 '19 at 19:23
  • The GET doesn't fix it. It just handles it in a better way i.e., it returns a message like "Your file upload was not processed correctly due to a timeout error. Please contact administrator at support@mysite.com." This is way better than a generic 524 error page from a DNS provider. – pandichef Nov 10 '19 at 19:50
  • You can't send a response with *anything* in it if there is a timeout, a timeout means that no response was received in time. – Quentin Nov 10 '19 at 19:52
  • Cloudflare has a 100 second timeout. It's always 100 seconds. I want to refresh the page with a GET after 99 seconds to sidestep the http timeout error. Does that make sense? – pandichef Nov 10 '19 at 20:11

1 Answers1

0

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".

pandichef
  • 706
  • 9
  • 11
  • 1
    I think this wont work. If you don’t intercept the submit event, the browser will actually submit the form (with either GET or POST depending on the submitted form method) and reload the page with the response. And then your timeout will be lost. – Jérôme Apr 26 '23 at 16:35