您的位置:首页 > 其它

ajax 异步加载 list集合数据

2016-01-29 00:00 204 查看
js端:

$(function(){

$.ajax({

url : '<c:url value="/app/doFindAPPMarketList.do"/>',

data : {

},

type : "POST",

dataType : "json",

success : function(data) {

var appList = data["appList"];

var userList = data["userList"];

for(var i = 0; i < appList.length; i++){

$(".getAppListClass").append("<option value='"+appList[i]["appid"]+"'>"+appList[i]["name"]+"</option>");

}

for(var i = 0;i < userList.length; i++){

$(".getAppMarketListClass").append("<option value='"+userList[i]["userId"]+"'>"+userList[i]["nickname"]+"</option>");

}

},

error : function(e) {

alert(e);

}

});

});

java 端:

public void doFindAPPMarketList(){

List<AppDto> appList = this.appService.doFindAll();

List<UserDto> userList = userService.doFindUsers();

JSONObject json = new JSONObject();

json.put("appList", appList);

json.put("userList", userList);

try {

response.setContentType("text/json; charset=utf-8");

response.getWriter().write(json.toJSONString());

response.getWriter().flush();

} catch (IOException e) {

e.printStackTrace();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: