使用 JavaScript 的 window.location.replace() 方法替代 location.href,代码示例如下:
$.ajax({
url: '/example/path',
method: 'GET',
success: function(response) {
// do something with response
window.location.replace('/new/path');
},
error: function(jqXHR, textStatus, errorThrown) {
// handle error
}
});
上一篇:Ajax响应格式化