0

I try to sending a form post as array in angularjs $http.

 //this is how i serialize it
 $("#formTest").serializeArray().map(function(x){data[x.name] = x.value;}); 

and if i put it into console.log. the result is

products[0][code]   azizi-hoho
products[0][price_total]    44
products[0][price_unit] 3

now i try to post those value using angular $http with post method. Then when i inspect the post data. it actually sending it like this.

products%5B0%5D%5Bcode%5D=azizi-hohoproducts%5B0%5D%5Bprice_total%5D=44products%5B0%5D%5Bprice_unit%5D=3

On the server side, if the post is successfull. The post data will then be grabbed by

$products = json_decode($_POST['products']);

But on this case, this doesn't happen, how do i make $_POST['products'] containing those data that i post.

Azizi Musa
  • 1,009
  • 2
  • 10
  • 31

0 Answers0