I have used POST request to the login API '/login' using JQuery (AJAX); and returned the dashboard page by return "redirect:/dashboard". In the network tab of my browser, on preview section I can see the requested page but it's not reflecting on the browser. Am I missing something to load that obtained page on the browser?
Asked
Active
Viewed 423 times
1
-
1You can redirect to the dashboard page in your ajax success. Post how you're redirecting(code) in your controller. – Lucky Oct 23 '16 at 11:22
-
1I don't want to use JS to redirect the page. I want to do that with Spring Framework. Here is the API used to handle the login request and redirect to dashboard. `@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(@RequestBody UserDto userDto){ logger.info(userDto.toString()); return "redirect:/dashboard"; }` – Nalin Adhikari Oct 23 '16 at 11:28
-
1sending a redirect response for an ajax request won't work in browsers. the easiest way to do this with spring is not to use ajax for login. see http://stackoverflow.com/questions/19346430/performing-a-normal-redirect-from-an-ajax-spring-mvc-controller-method. if you really want to use ajax, you can do something as mentioned here http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call – fischermatte Oct 23 '16 at 12:11
-
Thank you for your solution. I will go with it. – Nalin Adhikari Oct 23 '16 at 16:07