Untitled

mail@pastecode.io avatar
unknown
html
2 years ago
1.2 kB
1
Indexable
Never
$('body').on('click', '#submitForm', function () {
        var Form = $("#form");
        var formData = Form.serialize();
        $('#nama-error').html("");

        $.ajax({
            url: '/admin/save_regionals',
            type: 'POST',
            data: formData,
            success: function (data) {
                console.log(data);
                if (data.errors) {
                    if (data.errors.nama) {
                        $('#nama').addClass('is-invalid');
                        $('#nama-error').html(data.errors.nama[0]);
                    }
                }
                if (data.success) {
                    Swal.fire({
                        position: 'top-end',
                        icon: 'success',
                        title: 'Berhasil disimpan',
                        showConfirmButton: false,
                        timer: 1500
                    })
                    setInterval(function () {
                        $('#tambahModal').modal('hide');
                        window.location.reload();
                    }, 2000);
                }
            },
        });
    });