i want to access in my jquery script to the variable cardlist i put in the model:
@RequestMapping(value="/searchlostcard")
public
String searchlostcard(@ModelAttribute(value="searchform") SearchForm searchForm
,HttpServletRequest request, Map<String, Object> model) {
List<Lostcard> listlostcard = lostcardRepository.findByNom(searchForm.getValue());
model.put("cardlist", listlostcard);
return "search/results";
}
My jquery ajax call:
function searchAjax() {
$.ajax({
url : 'searchlostcard',
type: 'POST',
data:$('#formSearch').serialize(),
success : function(responce) {
/* how can i acces to my List of object (listlostcard) ? */
$('#page_grid').html(responce);
},
error : function(){
alert("error");
}
});
}
Listno longer exists on the client side.${something}expression into some String. The rendered text (which is simply HTML) is sent as the body of the HTTP response. Your browser receives that body, sees something likevar javascriptVar = "someText";, evaluates it and executes it. It's just text.