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 enter image description here

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

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -