I have a spring 3 application where i am using jquery to post ajax request. Now i want to redirect my page to another page after ajax response comes. A Pojo is returned by the 1st page controller, which is to be passed to 2nd contoller. i know how to redirect but have no idea how to pass this PoJo to next form controller
$.ajax({
type: "POST",
url: "/xxx/xxx/xxx/accept",
data: "bId=" + bId+
"&minDelTime=" +minDelTime,
success: function(response){
if(response.errorText == null) {
//this works fine
alert(response.orderId);
//this is where i have to redirect with response as parameter
window.location.replace("/xxx/xxx/xxx/confirm/"+response.orderId);
} else {
alert(response.errorText);
}
},
My next page controller –
@Controller
@RequestMapping("/xxx/xxx/confirm")
public class ConfirmationController {
@RequestMapping(value = "/orderVo", method = RequestMethod.GET)
public String showOrderConfirmPage(@PathVariable MasterVo orderVo, Model model) {
LOGGER.info("Entry showOrderConfirmPage()");
LOGGER.debug("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ : " + orderVo.toString());
LOGGER.info("Exit showOrderConfirmPage()");
return "/xxx/orderConfirmView";
}
}
But i am getting error always. Can someone please tell me how to pass object(Pojo) to new page controller?
Update –
I tried serializing object –
success: function(response){
if(response.errorText == null) {
$.post("orderVo", response.serialize(), function(data) {
window.location.replace("/xxx/xxx/xxx/confirm/");
});
but i am getting Uncaught TypeError: Object # has no method ‘serialize’
why not just redirect?