What is causing this error? I believe it is an incorrect accept header. Shouldn’t the jquery ajax method set that to the correct value when datatype: ‘json’?
406 Not Acceptable
Here’s my Spring Controller mapping:
@RequestMapping(value={"/{ID}"}, method=RequestMethod.GET)
public @ResponseBody Double getRating(@PathVariable(value="ID") final Long id,
@RequestParam Long rating) {
Double ratingResult = rate.get_rating(id);
return ratingResult;
}
Here’s my javascript:
$.ajax({
type:'GET',
url: '/ratings/' + ID + '?rating=' + rating,
datatype: 'json',
success: function(data){
var obj = jQuery.parseJSON( data );
var ratingResult = obj.ratingResult;
});
My accept header value is */*
Please verify the server side:
But if you have incorrect response content type it supposed to be application/json, remember what you need to add jackson to your /lib directory.
In your serlvet-name.xml file.
And please use firebug to see the json notation if you can catch the object response in your console.
Please verify the client side:
Examine your request headers:
Accept /
Accept: application/json, text/javascript, /; q=0.01
This will explicitly tell the server side that you are expecting JSON.
And… check this: http://www.checkupdown.com/status/E406.html