How to use serializeArray values ​​in php?

I got the size from the mold.

 resize = $('#resize_form').serializeArray();

      

I put the resize in hidden and post it to the php page. How to get size value in php?

<input type='hidden' name='name_print' value='resize '>

      

I am throwing out the value in the resulting php

name_print (String): "[object Object],[object Object],[object Object]  
,[object Object],[object Object]" (79 characters)  

      

I am using firebug and it shows this

 [Object { name="name_print", value="5555"}, Object { name="hem_up", value=""},  
 Object { name="hem_up_double", value="0"}, Object { name="hem_up_size", value="0"},  
 Object { name="waist_catch", value=""}]

      

How to use data in php? convert it to an array?

I am using JOSN.stringify data like this

[{"name":"name_print","value":"1111111111"},{"name":"hem_up","value":""},   
{"name":"hem_up_double","value":"0"},{"name":"hem_up_size","value":"0"},  
{"name":"waist_catch","value":""}]

      

+3


source to share


3 answers


You cannot put an array in a form field, you must first convert it to a string. You can put it in JSON format:

resize = JSON.stringify($('#resize_form').serializeArray());

      



Then in PHP you can use json_decode()

:

$resize = json_decode($_POST['name_print']);

      

+1


source


Try using serialize()

instead serializeArray()

. It creates a string with your form data for you to submit to the server.



0


source


   // in your php code
   $resizedata = json_decode(stripslashes($_POST['resize']),true);
   $resizeval = $resizedata['name_print'];
   print_r($resizeval);

      

0


source







All Articles