favorite-vacancy-45.blade.php 1.53 KB
<script>
    $(document).ready(function() {
        $(document).on('click', '.js_vac_favorite', function () {
            var _this = $(this);
            var id = _this.attr('id');
            var id_vacancy = _this.attr('data-val');

            if ($( "#"+id ).hasClass( "active" )) {
                $.ajax({
                    type: "GET",
                    url: "{{ route('like-vacancy') }}",
                    data: "code_record=" + id_vacancy,
                    success: function (data) {
                        ///
                    },
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    error: function (data) {
                        data = JSON.stringify(data);
                        console.log('Error: ' + data);
                    }
                });
            } else {
                $.ajax({
                    type: "GET",
                    url: "{{ route('like-vacancy') }}",
                    data: "code_record=" + id_vacancy + "&delete=1",
                    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>