Update table after AJAX success

0

I have a table in which a cell has the value 0 (inactive) and 1 (active) I update the values perfectly by ajax but if I give it to the same button it still sends the same value ... that is, I can activate or deactivate a record but then I can not activate or deactivate it again because it keeps sending the same value.

I think I need to refresh the data in the table so that it takes on the new value

$(document).on('click', '#btn6Si, #btn6No', function () {
var elem = $(this);
var activo = elem.text();
var className = elem.attr('class');
var id = elem.val();
var url = 'colleges_save3.php';
/*e.preventDefault();*/
var request = $.ajax({
  data: {id: id},
  type: "POST",
  cache: false,
  url: url,
  dataType: "html",
  success: function(response) {
      $('#resultado').html(response);
    if (response == 'verdadero') {    
      if (className == 'zmdi zmdi-star zmdi-hc-lg yellow') {
          elem.removeClass('zmdi zmdi-star zmdi-hc-lg yellow').addClass('zmdi zmdi-star zmdi-hc-lg grey');
          this.reset();
          $('#mitabla_id').html(data);
          $('#mitabla_id').ajax.reload();
          /*elem.text('SAT');*/
      } else if (className == 'zmdi zmdi-star zmdi-hc-lg grey') {
          elem.removeClass('zmdi zmdi-star zmdi-hc-lg grey').addClass('zmdi zmdi-star zmdi-hc-lg yellow');
          this.reset();
          $('#mitabla_id').html(data);
          $('#mitabla_id').ajax.reload();
          /*elem.text('SAT');*/
      }
    } else if (response == 'falso'){
        alert("El estudiante ya tiene asignada una universidad final. Si deseas cambiarla desactivala y vuelve a activar la universidad final deseada.");
        this.reset();
        $('#mitabla_id').html(data);
        $('#mitabla_id').ajax.reload();
          /*elem.text('SAT');*/
    }

  }
});
request.done(function(text) {
  console.log(text);


});

request.fail(function(jqXHR, textStatus) {
  alert("Error de petición: " + textStatus);
});

});

And where I call the function:

<td><?php 
<td><?php 
if ($row['final'] == 1) {?>
<button id="btn6Si" value="final-<?php echo $id_appl ?>-0" class="zmdi zmdi-star zmdi-hc-lg yellow" style="background:Transparent; border:Transparent"></button>
<?php } else if ($row['final'] == 0) {?>    
<button id="btn6No" value="final-<?php echo $id_appl ?>-1" class="zmdi zmdi-star zmdi-hc-lg grey" style="background:Transparent; border:Transparent"></button>
<?php } ?>
</td>
    
asked by Ivy League Education America I 11.12.2018 в 18:45
source

0 answers