Press "Enter" to skip to content

FastAdmin种Ajax请求

1、有一种表单操作型的请求Fast.api.ajax

这种默认是有提示的

2、还可以自己定义:

$.ajax({
    url: 'item/type/getParentByGrade/grade/' + gradeVal,
    type: 'get',
    dataType: 'json',
    $(document).on("change", "#selGrade", function(){
        let gradeVal = $(this).val();
        $.ajax({
            url: 'item/type/getParentByGrade/grade/' + gradeVal,
            type: 'get',
            dataType: 'json',
            success: function (res) {
                $('#selParentOption').selectPageData(res.data);
                if(res.data.length > 0) {
                    $('#selParentOption').val((res.data[0]).id);
                }
                $('#selParentOption').selectPageRefresh();

            }
        });
    });
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('T_grade')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="selGrade" class="form-control" name="row[t_grade]">
<option value="1">1级</option>
<option value="2">2级</option>
<option value="3">3级</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Parent_grade')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="selParentOption" data-pagination="false" data-rule="required" data-source='[{"id":"-1","name":"无"}]' data-max-select-limit="1" class="form-control selectpage" name="row[parent_grade]" type="text" value="-1">
</div>
</div>
发表评论