Hello Programmers I am working on an mvc project in an electronic entry to be more specific, I am trying to validate that if an employee is not authorized to enter an area the system generates a modal with the message of UNAUTHORIZED ACCESS attached the code to see what I'm doing wrong:
<div class="modal" id="NoAutorizado" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">No Autorizado</h5>
</div>
<div class="modal-body">
<h1>Acceso no autorizado</h1>
</div>
</div>
</div>
</div>
This is the code generated by the modal with bootstrap 4
<script>
$("#txtGafete").keypress(function (e) {
if(e.keyCode = 13)
{
var gafete = $("#txtGafete").val();
var mm;
$.ajax({
url: "http://localhost:49851/api/empleadoAutorizado/" + gafete,
method: "GET",
contentType: "application/json",
success: function (data) {
if (data == null) {
denegado();
} else {
$("#txtNombre").val(data.nombre);
}
}
});
}
});
</script>
The modality should be executed if the employee does not exist in the database is shown as null, I call it with the function denied in which I have the following code
function denegado()
{
$('#NoAutorizado').show();
setInterval(function () { $('#NoAutorizado').show('hide'), 3000 })
}
when executing the project the modal is activated when starting to introduce the employee's badge and what I try is to only show if the employee does not exist in my database that may be failing in my code, thank you for your comments