I've had the same problem. You can't send an object as "data", you need to stringify the object. Try this instead, with your object stringified:
$.ajax({
url: url,
type: 'POST',
contentType:'application/json',
data: '{
name:"test",
key:"foo",
key2:"bar"
}',
dataType:'json'
});