I'm getting a JSON that I created with PHP as described below, but when I try to access the properties of that JSON it always returns me undefined .
I made these test files there to demonstrate how I'm doing.
If I give a console.log
on the date, it returns me the JSON right
Can anyone help?
PHP function that returns me the JSON :
function listaAluno(){
$conn = Conexao::pegaConexao();
$stmt = $conn->prepare("SELECT * from tab_sys_student");
$stmt->execute();
$dados['data'] = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($dados);
}
JS function that accesses JSON :
function listaCurso(){
alert('listou');
$.ajax({
url: "restrict/checkUser.php",
type: "POST",
cache: false,
dataType : 'json' ,/*adiciona o tipo de retorno*/
error: function(){
alert('Erro ao Tentar ação.');
},
success: function (data) {
console.log(data.crs_id);
}
});
}