0
When saving the form to the database I want to show a success message to the user. I am trying to use sweetalert2
, but it’s not working. I already have the libraries:
<link rel="stylesheet" href="sweetalert2/dist/sweetalert2.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/8.11.8/sweetalert2.min.js"></script>
In the success of ajax I have this way, but it’s not working:
success: function(result)
{
$('.form4')[0].reset();
swal('Boa!', 'Gravado com sucesso!', 'success');
}
But I get the following mistake:
sweetalert2.min.js:1 Uncaught Typeerror: Cannot read Property 'constructor' of Undefined
Full function:
function inserir_registo()
{
var dadosajax = {
'Pedido' : $("#Pedido").val(),
'Assunto' : $("#Assunto").val(),
'Descricao' : $("#Descricao").val()
};
$.ajax({
url: './requisicaomanutencao12',
type: 'POST',
cache: false,
data: dadosajax,
error: function(){
$(".error_message").removeClass('hide');
swal("Erro!", "Tente novamente. Caso persista o erro, contatar Administrador!", "error");
},
success: function(result)
{
$('.form4')[0].reset();
swal('Boa!', 'Gravado com sucesso!', 'success');
}
});
}
Welcome. Where did you see this function
swal
in the documentation? On utilizing and example is being calledSwal.fire({ ... })
.– Renan Gomes