passing request params from jQuery to jersey service using json
- by ccduga
hi,
im trying to POST (cross domain) some data to a jersey web service and retrieve a response (a GenericEntity object). The post successfully gets mapped to my jersey endpoint however when i pull the parameters from the request they are empty..
$ .ajax({
type: "POST",
dataType: "application/json; charset=utf-8",
url: jerseyNewUserUrl+'?jsoncallback=?',
data:{'id':id, 'firstname':firstname,'lastname':lastname},
success: function(data, textStatus) {
$('#jsonResult').html("some data: " + data.responseMsg);
},
error: function ( XMLHttpRequest, textStatus, errorThrown){
alert('error');
}
});
this is my jersey endpoint..
@POST
@Produces( { "application/x-javascript", MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/new")
public JSONWithPadding addNewUser(@QueryParam("jsoncallback")
@DefaultValue("empty")
final String argJsonCallback, @QueryParam("id")
final String argID, @QueryParam("firstname")
final String argFirstName, @QueryParam("lastname")
final String argLastName)
is there something missing from my $.ajax call?