Retrieve object from jquery in php script

Posted by majc on Stack Overflow See other posts from Stack Overflow or by majc
Published on 2010-05-25T21:06:58Z Indexed on 2010/05/25 21:11 UTC
Read the original article Hit count: 238

Filed under:

I'm trying to rebuild an object encoded with Json but i'm not getting any value.


$.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?

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery