-1
It is giving undefined result, because I do not know how to put the value of $Validator[messages] (PHP) in the result of AJAX... I put it inside the html(.... " + data.messages + "...) but I don’t know if it’s like this...
// AJAX - Deletar
$(document).on("click", "#deleteEquip", function() {
var dados = {
buttonAcess: $('#acessDeleteEquip').val(),
admin_id: $('#admin_id').val(),
}
$.ajax({
url : "php_action/equip.php",
type: "POST",
data: dados,
async : true,
cache : false,
dataType : 'html',
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
success: function(data) {
console.log(data);
table.ajax.reload();
$('.modal-title').html('Deletar');
if(data.success){
$(".modal-body-info").html("<div class='alert alert-success ze-center'>Registro deletado com sucesso<br><i class='fas fa-thumbs-up ze-icon-g'></i></div>");
} else{
$(".modal-body-info").html("<div class='alert alert-danger ze-center'>" + data.message + "<br><i class='fas fa-thumbs-down ze-icon-g'></i></div>");
}
$('.modal-footer-button').html('');
$("#myModalMessage").modal("show");
},
error: function(error) {
console.error(error);
$('.modal-title').html('Deletar');
$(".modal-body-info").html("<div class='alert alert-danger ze-center'>Erro: Envio [3] (AJAX)<br><i class='fas fa-thumbs-down ze-icon-g'></i></div>");
$('.modal-footer-button').html('');
$("#myModalMessage").modal("show");
}
});
});
// AJAX - Deletar - End
if($buttonAcess == "acessDeleteEquip"){
$update = $datasource->deleteSelectedEquip($admin_id);
if($update) {
$validator['sucess'] = true;
} else {
$validator['sucess'] = false;
$validator['messages'] = "Erro: Alguma informação incorreta";
}
}