favorite-worker.blade.php 1.02 KB
<script>
    $(document).ready(function() {
        $(document).on('click', '.js_box_favorit', function () {
            var this_btn = $(this);
            var id_worker = this_btn.attr('data-val');
            var data = {code_record: id_worker};

            if (this_btn.hasClass('active')){
                data.delete = 1;
            }

            if (this_btn.hasClass('active')){
                this_btn.removeClass('active');
            } else{
                this_btn.addClass('active');
            }

            $.ajax({
                type: "GET",
                url: "{{ route('like_resume') }}",
                data: data,
                success: function (data) {

                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                error: function (data) {
                    data = JSON.stringify(data);
                    console.log('Error: ' + data);
                }
            });
        });
    });
</script>