1
I’m trying to assemble a table from a JSON that I receive from a page php, meanwhile when I do the append the captured value appears 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 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 by the url it displays 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’ve put some debug logs in. Someone’s been through this trouble?
What returns the
console.log(data)
?– Cezar
0: Array[1] 0: Object Dsc_name: "Category 01" Dt_fim_value: "2015-12-31" Dt_start_value: "2015-01-01" Id_evt_event: "528c234df006558ae470fa0ccabe7892" Id_evento_category: "528c234df006558ae470fa0ccabe7892" Vlr_registration: "100.00"
– Victor Hugo
in php appears like this:
– Victor Hugo
[[{"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"}]]
– Victor Hugo
Stick to the question what your file
getEventoCategoria.php
ago !!!– Cezar
put into question.
– Victor Hugo
in that line $arr[] = $Eventocategoria->selectCategoriesDoEvento($Id_evt_event); put some $arr = $Eventocategoria->selectCategoriesDoEvento($Id_evt_event); because you are creating array of array in my view! that will work !!!
– Cezar
HALLELUJAH............
– Victor Hugo
Was that right....
– Victor Hugo
Thank you very much.
– Victor Hugo
I think you’d better rule that out!
– Cezar