Angularjs $http.post, passing array to PHP -
i using service update db table.
myapp.factory('creategal', function ($http, $q) { return { creategal: function () { var deferred = $q.defer(); var newgalleryarray = {}; newgalleryarray.galleryname = 'new image gallery'; newgalleryarray.client = 245; $http.post('/beta/images/create', {newgalleryarray: newgalleryarray}).success(function(data) { console.log(data); deferred.resolve(data); }); return deferred.promise; } }; });
php
public function create() { print_r($_post); }
the array returning empty. passing array incorrectly?
chrome dev
thanks
it's been while since i've used php, doesn't $_post
contain request paramaters? $http.post
sends data through json payload, not request parameters. so, you'll need use json_decode
Comments
Post a Comment