Retrieve object from jquery in php script
- by majc
I'm trying to rebuild an object encoded with Json but i'm not getting any value.
JQuery:
$.post("views/insert_tasks.php",{ clickedRows : clickrows , <?php echo "tasks:'" . json_encode($tasks) . "'"; ?> }, function(data)
{
});
this is the PHPcode to retrieve the object:
$tasks = json_decode(stripslashes($_POST['tasks']), true);
$tasks is empty after execute the code above.
This is what I'm getting with the $_POST['tasks']:
[{"task_id":"1","description":"<p>Fazer heroi</p>","createdat":"Saturday 22nd of May 2010 11:37:37 PM","createdby":"Miguel Cardoso","max_requests":"2","max_duration":"5","job_id":"Concept Artist"},{"task_id":"2","description":"<p>teste2</p>","createdat":"Sunday 23rd of May 2010 11:23:55 AM","createdby":"Miguel Cardoso","max_requests":"2","max_duration":"5","job_id":"3D Modeller"},{"task_id":"3","description":"<p>teste3</p>","createdat":"Sunday 23rd of May 2010 11:45:39 AM","createdby":"Miguel Cardoso","max_requests":"1","max_duration":"10","job_id":"Writer"}]
What I'm doing wrong?