Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sweealert2 : Unknown parameter icon

Tags:

sweetalert2

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)
like image 279
jharrvis Avatar asked Nov 07 '19 05:11

jharrvis


2 Answers

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!

like image 90
Alan Miguel Rocha Avatar answered Nov 20 '22 01:11

Alan Miguel Rocha


The new major version (v9) was released a couple of days ago, please update your sweetalert2 dependency:

package.json:

"sweetalert2": "^9.0.0",

Or, if you're using CDN:

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>

Read the release notes to see all breaking changes: https://github.com/sweetalert2/sweetalert2/releases/tag/v9.0.0

like image 4
Limon Monte Avatar answered Nov 20 '22 00:11

Limon Monte