Is it bad practice to perform a redirection within an jQuery AJAX request?
$.ajax({
url: "myurl",
success : function(response) {
window.location.replace('MYNEWPAGE');
},
error: function (xhr) {
}
I’m experiencing some strange behaviour in an app and I think this is the issue.
location.replace()doesn’t store the current page into the browser history, the user can’t use the back button to go back onto the page. You should uselocation.assign(URL)orlocation.href = URL.