添加后台list给前台select标签赋值简单实现
添加后台list给前台select标签赋值简单实现
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下:$.ajax({url:"user!findUserList.action",type:"post",success:fu...

复制代码 代码如下:

$.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);

}

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新AJAX相关学习
热门AJAX相关学习
编程开发子分类