user1808995 user1808995 - 2 years ago 301
PHP Question

Decode JSON stringify in a different php file

function getstaff(){
var staffinfo = $('#group').val();
var myJSONText = JSON.stringify(staffinfo);
success: function(result){

How do I retrieve the posted data in staffDetails.php file. It some how gives me drastic errors. Can anyone suggest how exactly to retrieve what I sent to this php file

$data = JSON.parse($_POST['data'],',');
echo $data;

Answer Source

Use json_decode to decode a json array in PHP

 $data = json_decode($_POST['data']);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download