How can I send an array (a set of simular items) in a POST request to a RESTful API build with Codeigniter?
I can开发者_开发问答 send singular items like this:
name=John&email=demo@demo.com
But how can I send items like this and use them on the server side like an array?
keywords=blue,sky,weather,car,vacation
I would think you could send a json array depending on the capabilities of the backend. If the RESTful API consumes this content type you are able to then send an array by simply POSTing to the RESTful path, using the json array as the payload.
One way to send the payload would be with jQuery / AJAX:
.ajax({
url: "",
type: "POST",
contentType: "application/json",
data: JSON.stringify(jsonArray)
});
is it possible to send it in JSON?
{"keywords" : ["blue","sky","weather","car","vacation"]}
精彩评论