ajax三级联动使用onchange

Ajax使用onchange方法后怎么才能实现三级联动


报销明细一级信息:



报销明细二级信息:

        <div class="form-group">
            <label class="control-label col-xs-12 col-sm-2 no-padding" for="subjectThree">报销明细三级信息:</label>
            <div class="col-xs-12 col-sm-10">
                <div class="col-xs-12 col-sm-3">
                    <form:select id="subjectThree" path="subjectThree" class="chosen-select" data-placeholder="点击选择...">
                        <form:option value="" label=""/>
                        <form:options items="${subThreeList}" htmlEscape="false" />
                    </form:select>
                </div>
            </div>
        </div>



                     function subjectChanges1(obj){
     $('#subjectThree').empty();
    console.log('w');
    var subjectOne=$("#subjectOne").val();


    $.ajax({
        url:"${ctx}/expensesInfo/info/findsOId",
        type:"post",
        data:{'contentOne':subjectOne},
        success:function(data){

debugger
$("#subjectTwo").val("其他");
$("#subjectTwo").trigger("chosen:updated");
/* var htmlT="请选择......";*/
var htmlT="";//"+xxx+"";
for(var i=0 ; i htmlT += ""+data[i]+"";
}
$("#subjectTwo").html(htmlT)
$("#subjectTwo").trigger("chosen:updated");
$("#subjectThree").trigger("chosen:updated");

            // $("#subjectTwo").append(htmlText);
        }
    })

}

function subjectChanges2(obj){

debugger
var subjectTwo=$("#subjectTwo").val();
$.ajax({
url:"${ctx}/expensesInfo/info/findsWId",
type:"post",
data:{'contentTwo':subjectTwo},
success:function(data){
var htmlT="请选择......";
for(var i=0 ; i htmlT += ""+data[i]+"";
}
$("#subjectThree").html(htmlT)
$("#subjectThree").trigger("chosen:updated");
// $("#subjectTwo").append(htmlText);
}
})
}

我有点菜,没有数据模版展示,不好说,但是你这个问题我之前遇见过,我的办法是给子级/二级再添加一个key/pid,值就是父级的id,选中父级之后对子级的key/pid查找,一般是三级联动,也不是很麻烦,哈哈