SweetAlert2 (Swal is not defined) How to solve?

SweetAlert2 (Swal is not defined) How to solve?


When I click the button, no action is taken. On the "Console" I get the following message: "Uncaught ReferenceError: Swal is not defined". How to solve this, what is missing from my code?

I have the following in HTML:

  1. <button type="button" class="btn btn-primary btn-icon-text float-right mt-4 ml-2" data-idfinancial="{$id_financial}" id="sendmensagem">
                         <i class="btn-icon-prepend" data-feather="mail"></i> Enviar E-mail
                      </button>


The JS script looks like this:

  1. <script>
    $(document).ready(function() {

    $("#sendmensagem").click(function() {
    var thedataID = $(this).attr("data-idfinancial");
    $.ajax({
      async: true,
      type: "GET",
      url: 'send-financial.php?id=' + thedataID,

      success: function(data) {

      if (data == 'false') {
        // Sem erros

          Swal.fire({
            icon: 'success',
            title: 'Sucesso',
            text: 'Sua mensagem foi enviada!',
            footer: '<a href="javascript:;">Responderemos assim que possível.</a>',
            timer: 3000,
            timerProgressBar: true
          })

      } else {
        // Com erros

          Swal.fire({
            icon: 'error',
            title: 'Ops...',
            text: 'Algo deu errado!',
            footer: '<a href="javascript:;">Por favor, tente novamente mais tarde!</a>',
            timer: 3000,
            timerProgressBar: true
          })
      }
      },
      error: function(data) {
          console.log(data);
      }
    })
    })
    });
    </script>

PS: The CSS and JS files are set correctly.




--
Atenciosamente
Juscelino Barão