0

I am currently refreshing my page with

<script>function timedRefresh(timeoutPeriod){setTimeout('location.reload(true);',timeoutPeriod);}window.onload = timedRefresh(30000);</script>

But I am receiving a POSTDATA warning because it was wanting to resend a previous POST data form. I don't care of the post data is resent. It is not important for this site. I just want some way to refresh the page without the POSTDATA warning popping up.

Kade Williams
  • 1,041
  • 2
  • 13
  • 28

1 Answers1

1

The best way is to use PRG pattern, it prevents duplicate form submission. But if you still need a dirty way around (which is not recommended), you can use browser localStorage to maintain a flag.

timedRefresh(timeoutPeriod) { 
     localStorage.setItem('doResubmit', False);
     setTimeout(function () {window.location.reload(true);},timeoutPeriod);
}

Then, using localStorage.getItem('doResubmit'); just check whether or not you should send the request to server or not.

Let me know if it helps!

Anadi Sharma
  • 295
  • 1
  • 8
  • It doesn't look like this is refreshing the page. – Kade Williams Mar 10 '18 at 05:45
  • I wasn't answering for refreshing the page, intent was to give you a workaround for your POSTDATA warning issue. However, I just updated the answer. – Anadi Sharma Mar 10 '18 at 05:57
  • Thanks, I'll try that. I know it's a weird request. I'm actually writing a bare bones server and page using Python's baseHTTPserver. I display data that gets updated frequently. I currently refresh the page because of this. I have a Python function that allows the user to only display parts of that data instead of all of it. But if the page completely reloads, all of the data is displayed again. I know it's a weird hack. – Kade Williams Mar 10 '18 at 06:05
  • Do I need to keep my original code on the page along with yours in order for it to work? Or do I just add window.onload = timedRefresh(30000) to set the time? – Kade Williams Mar 10 '18 at 06:11