Search code examples
sweetalert2

Sweealert2 : Unknown parameter icon


I'm using sweealert2 on my project here's my code

header include js via jsdeliver.net

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8" charset="UTF-8"></script>

Jquery Version : jQuery v3.4.1

Script on footer

<script>
$(document).ready(function() {
    $("#updateUserProfile").submit(function(e) {
    e.preventDefault(); 

    var form = $(this);
    var url = form.attr('action');

    $.ajax({
           type: "POST",
           url: url,
           data: form.serialize(), 
           success: function(data)
           {
                $('.modal').modal('hide');
                var hasil = $.parseJSON(data);
                Swal.fire({
                    icon: 'info',
                    title: hasil.message,
                    showConfirmButton: false,
                    timer: 1500
                });
                // Swal.fire('Success', hasil.message, 'success', 1500)
                setTimeout(function(){
                    window.location.reload(1);
                }, 1500);
           }
         });
    });
});
</script>

ERROR on console.log

SweetAlert2: Unknown parameter "icon"

but when i use like this no error, and icon showing up

Swal.fire('Success', hasil.message, 'success', 1500)

Solution

  • try switch "icon", for "type", like this:

                   Swal.fire({
                        type: 'info',
                        title: hasil.message,
                        showConfirmButton: false,
                        timer: 1500
                    });

    I just had the same problem and found this solution!