1
Speaks My friends I have the following Modal:
I would like that when pressing save it closes the modal and updates only the table, I made the following code:
It is closing however gets dark td on the page and to use have to load td again with the F5:
Follows the JS Code:
$('#salvarPro').click(function() {
var Ndesc = $("#NDesc").val();
var Nqtd = $("#NQtd").val();
var Nvalor = $("#NValor").val();
$.ajax({
method: "POST",
url: "salvar.php",
data: {
desc: Ndesc,
qtn: Nqtd,
valor: Nvalor
}
}).done(function(resposta) {
$('#ModalNovo').hide();
alert(resposta);
GerarTabela();
}).fail(function() {
$('#ModalNovo').hide();
alert('falha ao Cadastrar');
GerarTabela();
});
});
And the HTML of Modal:
<div class="modal fade" id="ModalNovo" tabindex="-1" role="dialog" aria-labelledby="TituloModalCentralizado" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="TituloModalCentralizado">Novo</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Fechar">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="disabledTextInput">Desc</label>
<input type="text" id="NDesc" class="form-control">
</div>
<div class="form-group">
<label for="disabledTextInput">Qtd</label>
<input type="text" id="NQtd" class="form-control">
</div>
<div class="form-group">
<label for="disabledTextInput">Valor</label>
<input type="text" id="NValor" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
<button type="button" id="salvarPro" class="btn btn-success">Salvar Produto</button>
</div>
</div>
</div>
</div>
I agree, if you follow the bootstrap documentation, it’s the right thing to do
– Alisson Maciel