Reputation: 1457
I am in a specific page and I have a function on Javascript:
function goToAnotherpage(){
alert('goo');
$.ajax({
type : 'POST',
url : "/firstpage",
});
}
In Controller I enter inside the method firstpage
@RequestMapping(value="/firstpage", method = RequestMethod.POST)
public ModelAndView goToAnotherPage() throws ServiceException {
logger.debug("IT ENTER HERE);
return new ModelAndView("/secondpage");
}
I cannot enter in the second page. What is the problem?
Upvotes: 0
Views: 2089
Reputation: 4783
You can return the address and redirect in the javascript, something like this:
function goToAnotherpage(){
alert('goo');
$.ajax({
type : 'POST',
url : "/firstpage",
}).success(function(data){
window.location.href = "http://mypage" + data; // http://mypage/secondPage
});
}
Spring:
@RequestMapping(value="/firstpage", method = RequestMethod.POST)
public String goToAnotherPage() throws ServiceException {
logger.debug("IT ENTERED HERE");
return "/secondpage";
}
Upvotes: 1