JS file:
var jsonsave = [];
var dado = new Object();
dado.nome= "João";
dado.cpf = "000";
dado.teste = "teste";
var jason = JSON.stringify(dado);
jsonsave.push(jason);
$.ajax({
type: "POST",
dataType: "JSON",
url: "http://localhost/moodle/my/index.php",
data: "data="+jsonsave+"&ENVIO_RESPOSTAS=true",
success: function(data){
console.log('foi');
},
error: function(data)
{
console.log(data);
}
});
File php:
$arquivo = $_POST['data'];
$value= json_decode($arquivo, TRUE);
I call the php page through ajax, but I can not get the json values, come null, does anyone have any ideas?