用Ajax遍历三级下拉框

//通过一级分类的id查二级分类(记得在前端网页按钮绑定点击事件)

function getSecondCategory(oneCategoryId){
alert("a")
$.post("${pageContext.request.contextPath}/category/findSecondCategory",{"oneCategoryId":oneCategoryId},function(data){ $("[name='categoryLevel2Id']").html("<option value='0'>-请选择-</option>");
$(data).each(function(i,e){
var content = "<option value="+e.id+" onclick='getThirdCategory("+e.id+")'>"+e.name+"</option>";
$("[name='categoryLevel2Id']").append(content);
});
},"json");
}

//通过二级分类的id查三级分类
function getThirdCategory(secondCategoryId){
alert(“a”)
.post(&quot;.post(&quot;.post("{pageContext.request.contextPath}/category/findThirdCategory",{“secondCategoryId”:secondCategoryId},function(data){

		$("[name='categoryLevel3Id']").html("<option value='0'>-请选择-</option>");
$(data).each(function(i,e){
var content = "<option value="+e.id+">"+e.name+"</option>";
$("[name='categoryLevel3Id']").append(content);
});
},"json");
}
</script>

效果图用Ajax遍历三级下拉框-LMLPHP在这里插入图片描述

05-11 11:08