0
I have my table this way:
<div id="spoiler" style="display: none;">
<table class="table table-responsive" id="employee_table">
<h1 style="font-size: 30px"><strong>Saída de Luvas</strong></h1>
<thead>
<tr>
<th>Colaborador</th>
<th>Tipo Luva</th>
<th>Tamanho</th>
<th>Estado</th>
<th>Ação</th>
<th>Eliminar</th>
</tr>
</thead>
<tbody>
<tr>
<?php do{ ?>
<td><?php echo $produto["nome"]; ?></td>
<td><?php echo $produto["Tipo"]; ?></td>
<td><?php echo $produto["Tamanho"]; ?></td>
<td><?php echo $produto["Estado"]; ?></td>
td><button type="button" name="edit" id="<?php echo $produto["Id"]; ?>" data-toggle="modal" href="#add_data_Modal" class="btn btn-warning btn-sm edit_data" /><span class="glyphicon glyphicon-pencil"></span></button></td>
<td><button type="button" id="<?php echo $produto["Id"]; ?>" class="btn btn-dander btn-sm delete" onclick="remove(this)"/><span class="glyphicon glyphicon-trash"></span></button></td>
</tr>
<?php } while($produto = $result->fetch_assoc()); ?>
</tbody>
</table>
</div>
When I click on the edit button and then click on the record button I use the following Js
:
function inserir_registo()
{
var dadosajax = {
'Id' : $("#Id").val(),
'TipoLuvas' : $("#TipoLuvas").val(),
'Tamanho' : $("#Tamanho").val(),
'Quantidade' : $("#Quantidade").val(),
'Observacao1' : $("#Observacao1").val(),
'Estado' : $("#Estado").val()
};
$.ajax({
url: './atribuicaoluvas',
type: 'POST',
cache: false,
data: dadosajax,
error: function(){
$(".error_message").removeClass('hide');
},
success: function(result)
{
(function ($) {$(document).ready(function () {
$('#add_data_Modal').modal('hide');
});
})(jQuery);
}
});
}
I intend after closing the modal
within the success
update the table automatically and I’m not getting it.
I’m trying this way, but it doesn’t work:
$("#employee_table").table("refresh");
What changes the table is this query:
$query = "SELECT raddb.RequisicaoLuvas.Id, nome, Tipo, raddb.TamanhoLuvas.Tamanho, Quantidade, Observacao, DataRequis, raddb.Status.Estado
FROM raddb.RequisicaoLuvas LEFT OUTER JOIN raddb.TipoLuvas
ON raddb.TipoLuvas.Id = raddb.RequisicaoLuvas.TipoLuvas LEFT OUTER JOIN raddb.TamanhoLuvas
ON raddb.TamanhoLuvas.Id = raddb.RequisicaoLuvas.Tamanho LEFT OUTER JOIN raddb.usuarios
ON raddb.usuarios.id = raddb.RequisicaoLuvas.Colaborador LEFT OUTER JOIN raddb.Status
ON raddb.Status.Id = raddb.RequisicaoLuvas.Estado WHERE raddb.Status.Estado = 'Pendente'";
$result = $conn->query($query) or die($conn->error);
$produto = $result->fetch_assoc();
Because when I edit I change the status of pending to delivered and when changing I should leave the line that was edited.
Why do you have
.ready()
within thatsuccess
? You should only have$('#add_data_Modal').modal('hide');
. And when you say "update the table automatically" what do you expect to happen? I don’t see code that changes the table...– Sergio
@Sergio edited the question with the code that was missing
– Bruno
@Bruno, you must perform an ajax request that replaces your current table with an updated table
– Vinicius De Jesus