我正在对控制器进行AJAX调用,并且我希望重定向到Success上的新页面。所以我有我的成功回调函数中的重定向逻辑。但它不会重定向到新页面,而是保持在同一页面上。Spring MVC - 使用jQuery重定向
The intriguing thing is that a GET Request (with the form Data I just sent via POST) is made after the Ajax Callback is executed. that is, I see a GET Request in the Address Bar.
这里是我的AJAX请求
$.ajax({
url: "processData",
type: "POST",
dataType: 'json',
contentType:'application/json',
async: false,
data: JSON.stringify(req),
success: function(result) {
url = window.location.href;
url = url.replace("processData", "getMoreData");
alert(url); // correct url is printed
window.location.replace(url);
},
error: function() {
alert("--- Failure ---");
}
});
有什么错在这里?
在更改url后,将location.reload添加为最后一条语句。我认为它应该工作。 – NightsWatch
@PradeepSekar谢谢Pradeep,但它仍然不起作用。 – AgentX
我想知道!一旦你手动重新加载它的时候在窗口中有url,它会把你带到你期待的地方? – NightsWatch