我做错了什么使它停止工作

时间:2019-12-02 07:17:36

标签: jquery ajax laravel-5

Am使用ajax获取显示下拉菜单。它曾经在工作,但突然停了下来。网址运行良好,但数据也未显示在选项字段中。它只显示“ loding ...”。


$('#radclass').on('change',function(){
            var value = $(this).val();
            $('#raddrop').empty();
            $('<option>').val('').text('loading....').appendTo('#raddrop');
                let link = "{{url('fetch-rad')}}/"+value;
                //alert(link);

            $.get("{{url('fetch-rad')}}/"+value, function(data, status){
                var len = data.length;
                $('#raddrop').empty();
                $('<option>').val('').text('Choose Test').appendTo('#raddrop');
                if(len > 0){
                    $.each(data, function(k, v){
                        $('<option>').val(v.investigation_name)
                                    .text(v.investigation_name)
                                    .attr('data-test-id', v.id)
                                    .attr('data-test-class-id', v.radiology_class_id)
                                    .appendTo('#raddrop');

                    })
                }
            })
        });

这是html代码

<div class="form-group col-sm-6 radios">
                                            <label for="rads">Radiology< Department</label>
                                            <select class="form-control content__select main"  id="radclass" name="rad_class" >
                                                    <option value="">Select test</option>
                                                    @foreach($radiologyClass as $class)
                                                        <option value="{{ $class->id }}">{{ $class->class_name }}</option>
                                                    @endforeach
                                            </select>
                                            @if ($errors->has('rad_class'))
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>Please enter radiology test.</strong>
                                                </span>
                                            @endif
                                        </div>

                                        <div class="form-group col-sm-6 radios">
                                            <label for="rads">Radiology< Investigation</label>
                                            <select class="form-control content__select main" id="raddrop">
                                                <option value="">Choose Test</option>
                                            </select>
                                            <button id="minusbtn" type="button" class="btn btn-primary btn-sm">
                                                <i style="color: #4a90e2;" class="fa fa-plus-circle multi"></i>
                                            </button>
                                        </div>
``

0 个答案:

没有答案