I have an array of id's which I wish to pass as a parameter to a webservice via jQuery's $.post like so:
var selections = [1,2,3,4];
$.post('/save', {ids: selections, function(data) {
// do something
});
Unfortunately the code above submits multiple parameters (which is what I want) but it appends a '[]' to the parameters name so the params sent through when inspected with firebug look like:
ids[] 1
ids[] 2
ids[] 3
ids[] 4
The size of the array is dynamic so I can't hardcode it. Is there a dynamic way to do this without creating a parameter string manually?
Thanks, gearoid.
EDIT:
I should also mention that I'm submitting to a Jersey Webservice method which looks like the following:
@POST
@Path("save")
@Produces({"application/xml","application/json"})
@Consumes("application/x-www-form-urlencoded")
public Response save();