I want to POST
3 parameters to my PHP web service. One of which is an array, so I used JSON.stringify()
first and then added it as the parameter. The problem is, PHP isn't receiving the stringify'ed parameter.
My array is created by fetching IDs of each element in an object.
Converting it into a string:
var cid = JSON.stringify(cids);
Output as in the console for cid
:
["1","2","3"]
And my $http.post
call:
var dataObj = {
wid: wid,
type: type,
cid: cid
};
$http.post("my.php", dataObj);
From what I understand, the array gets converted into a string, which must get POSTed alike other strings, but when I echo back $_POST['cid']
, it turns out to be blank; while the wid
& type
are proper.