Edit File: get_category_subs.blade.php
<script> $(document).ready(function() { $('#category_id').change(function() { var categoryId = $(this).val(); console.log(categoryId); var url = "{{ route('get_category_subs', ':categoryId') }}"; url = url.replace(':categoryId', categoryId); if (categoryId) { $.ajax({ url: url, type: 'GET', dataType: 'json', success: function(response) { console.log(response); var sub_categories = response; $('#sub_category_id').empty(); $('#sub_category_id').append( '<optgroup label="{{ __('admin.select_sub_categories') }}"></optgroup>' ); if (sub_categories.length > 0) { $.each(sub_categories, function(key, value) { $('#sub_category_id').append('<option value="' + value.id + '">' + value.name.ar + '</option>'); }); $('#sub_category_id').prop('disabled', false); } else { $('#sub_category_id').prop('disabled', true); } } }); } else { $('#sub_category_id').empty(); $('#sub_category_id').prop('disabled', true); } }); }); </script>
Back to File Manager