ReferenceError: Swal is not defined

244 Views Asked by At

i got admins table in my working project that is developed in laravel 8 the admins table has delete option and other options as well i use sweet alert to confirm deleting i use

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

for the sweet alert package and the below is my code for delete function

    <script>
        $(document).on('click', '.delete', function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            Swal.fire({
                title: "Are you sure you want delete this item ? "
                text: "you will not be able to restore it !",
                type: "warning",
                showCancelButton: true,
                confirmButtonClass: 'btn-danger',
                confirmButtonText: 'Yes , delete it !',
                cancelButtonText: 'No , cancel the delete!',
                closeOnConfirm: false,
                closeOnCancel: false,
                preConfirm: () => {
                    $("form[data-id='" + id + "']").submit();
                },
                allowOutsideClick: () => !Swal.isLoading()
            })
        });
    </script>

i use this function a lot in the project but from no where the cdn didn't work suddenly and in console it show me this error GET https://cdn.jsdelivr.net/npm/sweetalert2@9 net::ERR_CONNECTION_RESET

and when click the delete button it show me this error ReferenceError: Swal is not defined

i tried to use the cdn for sweet alert 2 version 10 <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script> but it show me the same error

0

There are 0 best solutions below