Am using ajax to fetch display dropdown. It was working before but suddenly it stopped. The Url is working well but the data is nor displaying in the option field. Its just showing "loding...".
$('#radclass').on('change',function(){
var value = $(this).val();
$('#raddrop').empty();
$('<option>').val('').text('loading....').appendTo('#raddrop');
let link = "/"+value;
//alert(link);
$.get("/"+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');
})
}
})
});
Here is the html code
<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=""></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>
``
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire