I have a jQuery object which is appended to form field like,
var params = {
'product_id': productId,
'width': width,
'drop': drop
};
$("#sample-form input[name='params']").val(params);
Form looks like,
<form id="sample-form" action="url" method="post">
<input type="hidden" name="params"/>
<button type="submit">Submit</button>
</form>
On receiving this "params" using POST data in PHP, I get string with value "[object Object]"
How do I convert this into array?
...val(JSON.stringify(params)). Then deserialise that value when sent to your PHPval(JSON.stringify(params));. Then in PHP, you do:$params = json_decode($_POST['params'], true);to get it as a PHP array.