Reputation: 47
I got the resize from a form.
resize = $('#resize_form').serializeArray();
I put the resize in a hidden and send it to a php page.How to get the resize value in php?
<input type='hidden' name='name_print' value='resize '>
I dump the value in the received php
name_print (String): "[object Object],[object Object],[object Object]
,[object Object],[object Object]" (79 characters)
I use firebug and it show 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=""}]
I use the JOSN.stringify the 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":""}]
Upvotes: 3
Views: 4796
Reputation: 1
// in your php code
$resizedata = json_decode(stripslashes($_POST['resize']),true);
$resizeval = $resizedata['name_print'];
print_r($resizeval);
Upvotes: 0
Reputation: 780723
You can't put an array into a form field, you have to convert it into a string first. 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']);
Upvotes: 1
Reputation: 63
Try to use serialize()
instead of serializeArray()
. It creates a string with your form data so you can send it to the server.
Upvotes: 0