I am having a problem with my jQuery function that I am trying to achieve is to populate the data in a list
Javascript function
function load() { $.getJSON('${findAdminGroupsURL}', { ajax : 'true' }, function(data) { var html = '<option value="">Groups</option>'; var len = data.length; for ( var i = 0; i < len; i++) { html += '<option value="' + data[i].name + '">' + data[i].name + '</option>'; } html += '</option>'; $('#selection').html(html); }); }
Server side
@RequestMapping(value = "groups", method = RequestMethod.GET) public @ResponseBody List<Group> getGroups() { return this.businessGroups(); }
I call the load () function when loading, it runs the getGroups () function and returns the list successfully, but the problem is that getGroups () is complete
Function
(data) does not load, never falls into this function, but an error
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find an acceptable view
Can't I send a list of group objects or should it be a primitive Java type?
source share