0
Well, some time ago I made a feature on my site consisting of performing a filter (called AJAX), and in my action I simply return a view (at the moment I’m rendering via callback, but if possible I would like to own Modelandview was responsible for this).
Calling for AJAX:
function perfectDestinationFilter(){
$.ajax({
type: "GET",
url: "/viatge/perfect-travel-filter",
data: $('#form-filter-perfect-travel').serialize(),
success: function (response) {
$('html').html( response );
},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError);
}
});
}
Action responsible in return my page with the destinations found:
@RequestMapping(value = "/perfect-travel-filter", method = RequestMethod.GET)
public ModelAndView getDestinations(@RequestParam String social, @RequestParam String economic, @RequestParam String trip, @RequestParam String weather, @RequestParam String general, Model model) throws SQLException{
if(Strings.isNullOrEmpty(social) || Strings.isNullOrEmpty(economic) || Strings.isNullOrEmpty(trip) || Strings.isNullOrEmpty(weather) || Strings.isNullOrEmpty(general)){
return new ModelAndView("site/destinations02", "perfectDestinationError", true);
}else{
return new ModelAndView("site/destinations02", "perfectDestinations", destinationFacade.filterDestinations(economic, general, social, weather, trip));
}
}
Well, that approach even works through callback ($('html').html( response );
), but the problem is that the page renders with layout broken and not counting some functions jQuery do not work perfectly.
Is there any other possibility? Would I avoid the callback leaving the responsibility to the Tilesviewresolver accomplish this?