JS not resubmit form if reload page

Hi everyone!
I have a file in js structured like this:

if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}

This function blocks the pop-up that requires the module to be sent back to the update after sending the form. Works on all devices and browsers less than for Safari. I was wondering if there is an alternative…

Thanks

The old-school solution to this is to have the backend send a 302 redirect to the destination page after it receives the post. The javascript solution is nice when you don’t have the cooperation of the backend.

the problem is that I don’t have to redirect myself to another page but always remain in the same post. So when I finish the post procedure I don’t do a header()