Error retrieving json on php side

2

Well, I am sending a json to php but I can not recover

$.ajax({
    type: "POST",
    url: "sys/salvar_servidor",
    datType: 'json',
    data: JSON.stringify(dados),
    success: function( data ){
        document.write(data);
    }
});

And in PHP

<?php 

$dados = $_REQUEST['dados'];

$obj = json_decode($dados);

echo  $obj->nome; 

?>

The problem is that PHP returns me an error stating that the data variable is not defined.

    
asked by anonymous 29.12.2015 / 12:36

1 answer

2

Set the name of the field that will send json, the current way it is sent without a name, do

data: {'dados': JSON.stringify(dados)},
    
29.12.2015 / 12:41