I have a method annotated with @ResponseBody that return xls file and works fine if is normla post request.
Now I need to show on the view a loading effect. So first show loading ajax popup, second I call method with ajax post but i don't know how to handle response on success to download or open the file and close the popup.
Can you recommend me another strategy?
Now the code is like this.
//Controller
@RequestMapping(value = "/generateXls", method = RequestMethod.POST)
@ResponseBody
public void generateXls(@ModelAttribute Filter filter, HttpServletRequest request, HttpSession session, HttpServletResponse response)
throws Exception
{
/*Code for generate xls*/
}
//View
//function called on form submit.
function callGenerateXls() {
/* SHOW LOADING POPUP */
$.ajax({
type: 'POST',
url: "report/generateXls",
data: $("#filter").serialize(),
success: function(result) {
/* HOW TO HANDLE RESULT ????? */
/* HIDE LOADING POPUP */
}
});
}