How can i get my object array serializable in jquery to php ?
I have this:
I need get this array sent by jQuery(vetDespesas)
in php to create my sql query.
I try use dump php serialize
, unserialize
but it won't work.
I use this in jQuery:
// this = my Form html
var dataSend = $(this).serializeArray(); // other datas...
dataSend.push({name:'moeda',value:moeda});
dataSend.push({name:'moedaCotacao',value:moedaCotacao});
**dataSend.push({name:'vetDespesas',value:vetDespesas});** object array
and in php, how can I write the code?
$requisitadopor = $_POST['requisitadopor'];
$autorizadopor = $_POST['autorizadopor'];
$departamento = $_POST['departamento'];
$unidade = $_POST['unidade'];
var_dump($_POST['vetDespesas']); // doesn't work =/ (array of objects)
vetDespesas = JSON.stringify(vetDespesas);
and i php use:
$a = json_decode($_POST['vetDespesas']);
var_dump($a[0]);
My chrome console print:
object(stdClass)[2] public 'dataDespesa' => string '15/12/2015' (length=10) public 'descDespesa' => string 'teste1' (length=6) public 'budgetDespesa' => string '001 001 0E2R' (length=12) public 'valorDespesa' => string '2133.33' (length=7)How can I access this data?