信息发布→ 登录 注册 退出

添加后台list给前台select标签赋值简单实现

发布时间:2026-01-11

点击量:
复制代码 代码如下:
$.ajax({
url : "user!findUserList.action",
type : "post",
success: function(data){
var jsonObj=eval("("+data+")");
$.each(jsonObj, function (i, item) {
jQuery("#userList").append("<option value="+ item.userId+">"+ item.userRealName+"</option>");
});
},
error: function(text) {}
});

复制代码 代码如下:
public void findUserList() throws IOException {
List<UserModel> roleuserList = userService.findUserList();
String json = JSONArray.fromObject(roleuserList).toString();
writeHtml(json);;
}

复制代码 代码如下:
protected void writeHtml(String strData) {
try {
response.setContentType("text/html; charset=UTF-8");
PrintWriter pw = response.getWriter();
pw.write(strData);
pw.flush();
pw.close();
} catch (IOException e) {
log.error("writeHtml()", e);
}
}
标签:# text  # ajax  # BR  # span  # findUserList  # user  # url  # jsonObj  # userRealName  # gt  # userId  # public  # list  # error  # option  # jQuery  # item  # eval  # lt  # append  # userList  # 赋值  # select标签  
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!