GetJSON function does not display information on the screen

0

Good Night People, I really need some help.

I'm dynamically mounting a table that lists an X quantity of calls. For this I am using AJAX to query in the database and display on the page. So good, no problem.

But one of the items that I need to display in this listing is the "types of calls" that were made for each specific call.

Example: "In attendance ID 5223 on behalf of João da Silva, attendance was given to: Credit Card, Special Check and CDC."

Given this, I set up an array that contains the IDs of the call types and through these IDs in thesis I go back to the database to get the name of those calls and also list it on the screen for the user. >

It is important to note that a customer service can have 01 or more types of services.

Anyway, the X of the question is that I'm using the getJSON function to fetch this information from the types of queries.

However, it does not show me anything on the screen.

If I put the result in an alert (), I can verify that it is looking for the result normally. However the user screen does not appear.

I've studied the above for non-asynchronous AJAX requests, and have even tried to implement code changes. And none worked, so I really had no vision to solve it.

If you can help me find a way.

I am just copying the relevant part of the code. Before that part has only one SUCCESS of AJAX.

Follow 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>";

}
    
asked by anonymous 19.12.2018 / 01:05

0 answers