0
Talk to the guys, all right? I have a boring problem, and as I have never used AJAX in my life I think the problem is me :( Basically it’s like this, I have a GET that returns me the following JSON:
{
"result": 1,
"content": [
{
"PessoaId": "2",
"PessoaNome": "Otavio",
"PessoaTimeId": "1",
"PessoaCategoriaId": "0",
"Treinos": [
{
"TreinoId": "2",
"TreinoNome": "Resistencia",
"TreinoData": "2015-10-19",
"TreinoHorario": "15:44:00",
}
]
}
],
}
Okay, so I have my web page that wants to list people. Everything quiet until then, listing, editing, deleting etc. But I want to have the option to click on an icon and open a modal with the TRAININGS of that person in question. The problem is there, I did something but it didn’t work. Follow the code:
function getTreinos(AvaliacaoId){
var url = '../getters/getAvaliacaoById.php?TimeId='+TimeId+'&AvaliacaoId='+AvaliacaoId;
var data = "";
$.get(url, function(response){
serverResponse = response;
console.log(response.content.Treinos);
if(response.result == 1){
for(i in response.content.Treinos){
console.log(response.content.Treinos);
data +='\
<tr>\
<td> </td>\
<td>'+response.content[i].Treinos.TreinoNome+'</td>\
<td></td>\
<td>'+response.content[i].Treinos.TreinoData+'</td>\
<td>'+response.content[i].Treinos.TreinoHorario+'</td>\
<td>'+response.content[i].Treinos.TreinoFinalizado+'</td>\
<td></td>\
</tr>';
}
$('.treino-body').append(data);
var width = new Array();
$(".treino-body tr:eq(0)").find('td').each(function (position){
width[position] = $(this).outerWidth();
});
$(".treino-header tr").find('th').each(function (position){
$(this).css("width", width[position]+5);
});
callModalNovo();
}
else
alert(response.exception);
});
}
He, when he opens the modal, gives me that the attributes are Undefined. I looked around and it seems that it is something with the synchronization of AJAX. Does anyone have any other logic to do this? Grateful
So, I kind of modified it to stick here haha, but the original ta ok, I already tested it on Postman
– LMaker