passing request params from jQuery to jersey service using json
Posted
by ccduga
on Stack Overflow
See other posts from Stack Overflow
or by ccduga
Published on 2010-06-15T16:05:08Z
Indexed on
2010/06/17
23:53 UTC
Read the original article
Hit count: 311
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?
© Stack Overflow or respective owner