I have a modal that opens at the end of an action (Example: Disable User). I'm building the modal and wanted it to get the text present in an ajax variable. Verify code:
$.ajax({
url: "desativarUsuario.php",
type: 'post',
data: {
codigosDesativar: paraDesativar.map(function () {
return this.cod_user
}).get()
},
success: function (resposta) {
resposta = JSON.parse(resposta);
console.log(resposta, typeof resposta, typeof resposta[0], resposta[1]);
if (resposta[0]) {
var tabela = $('#tableUsuario tr');
$.each(tabela, function(index, tr) {
var checkbox = $(tr).find("input:checkbox");
if ($(checkbox).is(':checked')) {
$(tr).find(".status").text("Inativo");
$(tr).find(".status").css("color", "#BD362F");
$(tr).find(".inativo").addClass('hide');
$(tr).find(".ativo").removeClass('hide');
}
});
}
alert(resposta[1]);
}
});
Variable resposta
returns: Array [ true, "Usuário foi desativado com Sucesso!" ]
How to pass in the modal below this message "User was deactivated successfully!":
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Confirmation</h4>
</div>
<div class="modal-body">
<p>AQUI QUERIA A MENSAGEM@!!!!!!</p>
<p class="text-warning"><small>If you don't save, your changes will be lost.</small></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>