0
I’m getting a JSON that I created with PHP as described below, however, when I try to access the properties of this JSON he always returns to 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 to me the JSON straight
Someone can help?
Function PHP 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);
}
Function JS who accesses the 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);
}
});
}
How’s the checkUser.php file?
– Lucas de Carvalho
Is this php function ai
– Erick Anderson
You want to return only 1 bank record or all?
– Sam
I want the whole bank.
– Erick Anderson
If it is all, it will return several
data.crs_id
... which one you want to capture in particular or want to capture all?– Sam
I need all of you.
– Erick Anderson
I made a change in my reply, but see if any of the two answers.
– Sam