js端:java
$(function(){ajax
$.ajax({json
url : '<c:url value="/app/doFindAPPMarketList.do"/>',app
data : {this
},url
type : "POST",spa
dataType : "json",utf-8
success : function(data) {get
var appList = data["appList"];it
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();
}
}