you can do something like that.
$.ajax({ url: "your url here", type: "POST", data: { field1: "value1", field2: "value2", field3: "value3" }, success: function (response) { if (response.successFlag) { //Replace current location from the history via history API window.history.replaceState({}, 'foo', '/foo'); window.location = "url of target location here if you want to send a get request"; $("#form-id").submit();//if you want to post something up } } });
I think maybe you will also get rid of the need to delete history using this approach.
OR
You can use the following to replace the current page entry from the history and submit your form.
window.history.replaceState({}, 'foo', '/foo'); $("#form-id").submit();
OR
you can use the following code when the next page loads, and you want to remove the entry from the next page from the history:
window.history.replaceState({}, 'foo', '/foo');
Allan chua
source share