html部分代码
<div class="fitem">
<label>上级菜单:</label>
<input id="top-menu" class="easyui-combobox" name="parent_id"
data-options="valueField:'id', textField:'text',editable:false,onBeforeLoad:function(){LoadRewardObject();},width:'100px'"
/>
</div>
js部分代码
function LoadRewardObject(){
$.ajax({
url:"<%=request.getContextPath() %>/menu.html?act=list",
data:{},
method:"get",
success: function (data) {
var topMenu = data.filter(item => item.parentId == 0)
console.log("top-menu:",$("#top-menu"))
var topMenuNew = [{ 'text': '顶级菜单', 'id': '0'}];
topMenu.forEach((item)=>{
topMenuNew.push({ "text": item.name, "id": item.id });
})
$("#top-menu").combobox("loadData", topMenuNew);
}
})
}
url是请求后台的地址替换成你的接口地址就好了