Created
November 9, 2020 14:02
-
-
Save viniciusmelocodes/8db3eef0363bd50a9854e79f1e49e1aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function registrarAcesso() { | |
let codigo_acesso = $('#codigo-acesso').val(); | |
$.ajaxSetup({ | |
headers: { | |
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
} | |
}); | |
return $.ajax({ | |
url: '{{route("registrar_acesso")}}', | |
type: 'POST', | |
data: { | |
codigo_acesso: codigo_acesso, | |
}, | |
success: function (response) { | |
Swal.fire({ | |
title: 'Sucesso', | |
text: 'Acesso registrado com sucesso.', | |
icon: 'success', | |
confirmButtonText: 'Fechar' | |
}) | |
limparCampoPesquisa(); | |
$('#modalPesquisaRegistro').modal('hide'); | |
}, | |
error: function (response) { | |
if (response.responseJSON[0] == 'warning') { | |
Swal.fire({ | |
title: 'Aviso!', | |
text: response.responseJSON.mensagem, | |
icon: 'warning', | |
confirmButtonText: 'Fechar' | |
}) | |
} else { | |
Swal.fire({ | |
title: 'Erro!', | |
text: 'Comunique ao administrador do acesso sobre erros. Detalhes: ' + response.responseJSON.message, | |
icon: 'error', | |
confirmButtonText: 'Fechar' | |
}) | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment