0
Good evening Guys, I really need some help.
I’m dynamically setting up a table that lists an X number of calls. For this I am using AJAX to query the database and display on the page. So far so good, no problem.
But one of the items that I need to display in this list are the "types of care" that were performed in each specific service.
Example: "No atendimento ID 5223 em nome do João da Silva, They were conducted calls aimed at: Credit Card, Special Check and CDC."
Having seen this, I set up an array that contains the ID of the types of calls and through these Ids in theory I go back to consult the database to get the name of these calls and also list myself on the screen for the user.
Important to note that a customer service can have 01 or more types of services.
Anyway, the X of the question is that I am using the getJSON function to search for this information of the types of services.
Yet she shows me nothing on the screen.
If I put the result in an Alert(), I can verify that it is searching the result normally. However the user screen does not appear.
I studied the AJAX requests without asynchrons, and I even tried to implement changes in the code. And none of it worked out, so I was really left with no vision to sort it out.
If you can help me find a way.
I am only copying the most important part of the code. Before that part there is only one AJAX SUCCESS.
Follows the code:
var retorno = JSON.parse(data);
var linha = "";
for (var i = 0; i < retorno.length; i++) {
var tipos = retorno[i].tipo.split(',');
linha += "<tr>";
linha += "<td class='text-center'><h6 class='text-default font-weight-semibold letter-icon-title'>" + retorno[i].codigo + "</h6></td>";
linha += "<td class='text-center'><h6 class='mb-0'>" + retorno[i].senha + "</h6><div class='font-size-sm text-muted line-height-1'>senha</div></td>";
linha += "<td>";
linha += "<a href='#' class='carregaDados text-default font-weight-semibold' data-toggle='modal' data-target='#modal_visualiza_atendimento' data-id='" + retorno[i].codigo + "'>" + retorno[i].cliente + "</a>";
for (var a = 0; a < tipos.length; a++) {
$.getJSON("funcoes/carregaTipoAtendimento.php?tipo=" + tipos[a]).done(function(t) {
linha += "<span class='badge badge-flat border-" + cor + " text-" + cor + "'>" + tipo + "</span>";
});
}
linha += "</td>";
linha += "<td class='text-center'><i class='icon-calendar3 position-left'></i> " + retorno[i].data + "</td>";
if (retorno[i].prazo == "sim") {
linha += "<td class='text-center'><span class='badge bg-success'>" + retorno[i].duracao + "</span></td>";
} else {
linha += "<td class='text-center'><span class='badge bg-danger'>" + retorno[i].duracao + "</span></td>";
}
linha += "<td class='text-center'><img src='assets/images/" + codigo_convenio + "/" + retorno[i].usuario + ".jpg' class='rounded-circle' width='40' height='40'></td>";
linha += "</tr>";
}
Remembered to add the header in the reply?
– edson alves
Why not bring this data along with each item
retorno[i]
? Simpler and more efficient. The problem of this current code is that it is no longer useful to want to change the variablelinha
in the getJSON response, it’s too late for that.– bfavaretto