Search code examples
javascriptpost

How to reload page with javascript without sending POST information again


I have a page, to which I POST information via form method="post". I would like to relaod it with JavaScript, but location.reload(true) and location.reload() makes browsers ask if I want to send the POST data again.

I would like to make JavaScript reload the page with GET instead of POST to skip the POST data.

How can I achieve that?


Solution

  • window.location.href = window.location.href
    

    try

    UPD:

    there are other options as well:

    Prevent Form Resubmission Warning:

    window.history.replaceState(null, null, window.location.href);
    window.location.href = window.location.pathname;
    

    Firefox:

    window.location.reload(true) https://developer.mozilla.org/en-US/docs/Web/API/Location/reload