Error showing Json data

0

Why does undefined mark me when viewing the Json data?

Code Javascript :

function getNota()
{
    var id_temporada = $("#temporadaVal").val();
    var jornada = $("#jornadaVal").val();

    $.ajax({
        type: "POST",
        url: "../includes/acciones/nota/getNota.php",
        data: "id_temporada=" + id_temporada + "&jornada=" + jornada, 
        async: true,
        success: function(data)
        {   
         var nota = jQuery.parseJSON(data);
         alert(nota.id_nota);
         //$("#id_notaVal").val(nota.id_nota);
         //$("#nota").html(nota.nota);
        }
    });
}

Php code getNote.php

<?php
include_once("../../clases/class.Juego.php");
include_once("../../clases/class.Nota.php");

extract($_POST);
# id_temporada
# jornada

$fecha = Juego::getFecha($jornada);

$nota = Nota::getNota($id_temporada, $fecha);

$arrayNota = array();

if(is_array($nota))
{
 $arrayNota[] = array("id_nota" => $nota[0]["id_nota"], "nota" => strip_tags($nota[0]["nota"]));
}

echo json_encode($arrayNota);
?>
    
asked by Jorge Alonso 21.12.2018 в 20:11
source

1 answer

0

I solved the problem, reading some of the comments that they put me, what is an array and not an object, so at the moment of showing the data I had to put the position in which that data is found.

function getNota()
{
    var id_temporada = $("#temporadaVal").val();
    var jornada = $("#jornadaVal").val();

    $.ajax({
        type: "POST",
        url: "../includes/acciones/nota/getNota.php",
        data: "id_temporada=" + id_temporada + "&jornada=" + jornada, 
        async: true,
        success: function(data)
        {   
         var nota = jQuery.parseJSON(data);
         alert(nota[0]["id_nota"]);
         //$("#id_notaVal").val(nota.id_nota);
         //$("#nota").html(nota.nota);
        }
    });
}
    
answered by 03.01.2019 / 19:48
source