I am having problem with my jQuery function what I am trying to achieve is to populate data in a listbox
The 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);
});
}
The server side is
@RequestMapping(value = "groups", method = RequestMethod.GET)
public @ResponseBody
List<Group> getGroups() {
return this.businessGroups();
}
I call load() function on load it triggers the function getGroups() and returns the list successfully but the problem is once the getGroups() is finished
function(data) doesn't load never gets into that function and the error is
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation
Can't I post back a list of Group objects, or does it have to be a Java primitive type?
A similar post I found today ..
Spring's Json not being resolved with appropriate response
Hope this might help
http://forum.springsource.org/showthread.php?85034-HttpMediaTypeNotAcceptableException-(always)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With