i want post
3 parameters php web service. 1 of array, used json.stringify()
first , added parameter. problem is, php isn't receiving stringify'ed parameter.
my array created fetching ids of each element in object.
converting string:
var cid = json.stringify(cids);
output in console cid
:
["1","2","3"]
and $http.post
call:
var dataobj = { wid: wid, type: type, cid: cid }; $http.post("my.php", dataobj);
from understand, array gets converted string, must posted alike other strings, when echo $_post['cid']
, turns out blank; while wid
& type
proper.
from understanding post data converted json anyway. manually changing array json , including same as:
$http.post("my.php", { wid: wid, type: type, cid: [1, 2, 3] }
at other side of connection json converted objects(arrays) if possible. php doesn't print because arrays aren't converted strings well. although should expect string 'array'. try echo'ing $_post['cid'][0]
edit:
stated in comments , this post following code required php , angularjs play together:
$postdata = file_get_contents("php://input"); $request = json_decode($postdata);
Comments
Post a Comment