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