使用以下代码将数组参数转换为JSON对象发送:
var data = {arrayParam: [1, 2, 3]};
$http.post(url, data)
.then(function(response) {
// success code here
}, function(error) {
// error code here
});
在服务器端,您可以使用解码JSON对象的任何程序来处理POST请求的参数。例如,在PHP中,使用以下代码解码请求中的参数:
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$arrayParam = $data['arrayParam'];