I made a function in the model and the call in the controller. There, I move to jquery and the command to write to DB is successfully executed. It happens, that when I finish recording, the screen continues with the previous information, that is, the textbox filled, the checkbox's checked. How do I do after recording in BD (ajax success) I reload the page or changed fields only? Below my jquery call. The alert with the message can be disregarded, if necessary.
var checkedItemsUn = {}, checkedItemsMot = {}, checkedItemsPdv = {}, counter = 0;
function Gravar() {
$("#check-list-box li.active").each(function (idx, li) {
checkedItemsUn[counter] = $(li).text();
counter++;
});
counter = 0
$("#check-list-box-mot li.active").each(function (idx, li) {
checkedItemsMot[counter] = $(li).text();
counter++;
});
counter = 0
$("#check-list-tipo li.active").each(function (idx, li) {
checkedItemsPdv[counter] = $(li).text();
counter++;
});
counter = 0
str = "";
$.ajax({
url: '/CadastroCargo/GravaResponsavel',
datatype: 'json',
contentType: 'application/json;charset=utf-8',
type: 'POST',
data: JSON.stringify({ _responsavel: $('#txtResponsavel').val(), _ativo: $('#ckbAtivo').prop("checked"), _Un: checkedItemsUn,
_motivo: checkedItemsMot, _pdv: checkedItemsPdv, _nivel: $('#cbxNivelResp').val()
}),
success: function (data) {
str += '<div class="alert alert-success col-md-6">';
str += '<button type="button" class="close" data-dismiss="alert"></button>';
str += '<h4>Operação realizada com sucesso!</h4>';
str += 'Registro gravado no banco de dados com sucesso.';
str += '</div>';
$('#alerta').html(str);
str = "";
},
error: function (error) {
}
})
}