Capturing value $ .getJson is coming undefined

1

I'm trying to mount a table from a JSON I get from a php page, however when I do the append the captured value appears such as undefined .

$.getJSON("getEventoCategoria.php", {ID_EVT_Evento: ID},function (data) {
                var tabledata = "";
                console.log(data);
                console.log(data[0].DSC_Nome);
                $.each(data, function (index, item) {
                    console.log(item.DSC_Nome);
                    console.log(item.VLR_Inscricao);
                    
                    $('#conteudoTabelaCategoria')
                            .append(
                                    "<tr>" +
                                    "<td>" + item.DSC_Nome + "</td>" +
                                    "<td>" + item.VLR_Inscricao + "</td>" +
                                    "<td>" + item.DT_Inicio_Valor + "</td>" +
                                    "<td>" + item.DT_Fim_Valor + "</td>" +
                                    "</tr>"
                                    );
                });
            });

in the php file:

<?php

$ID_EVT_Evento = $_REQUEST['ID_EVT_Evento'];
require_once './actions/aEvt_Evento_Categoria.php';

$EventoCategoria = new aEvt_Evento_Categoria();

$arr[] = $EventoCategoria->selectCategoriasDoEvento($ID_EVT_Evento);

echo json_encode($arr);

When I do a direct get through the url it shows me the following JSON:

[[{"ID_Evento_Categoria":"528c234df006558ae470fa0ccabe7892","DSC_Nome":"Categoria 01","VLR_Inscricao":"100.00","DT_Inicio_Valor":"2015-01-01","DT_Fim_Valor":"2015-12-31","ID_EVT_Evento":"528c234df006558ae470fa0ccabe7892"}]]

I put some logs to debug. Has anyone had this problem yet?

    
asked by anonymous 07.10.2015 / 16:22

1 answer

2

Solved. I just removed the "[]" in the variable "arr" in the php file.

    
07.10.2015 / 16:43