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();
}
}
$(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();
}
}
相关文章推荐
- 厦门巨游网络科技有限公司(HOTPOWER)承接游戏UI外包
- ZBrush插件ZAppLink
- 2016/01/29 Scala学习4
- 在蜂窝教育开始我的Java之路
- android-View 的渲染
- VIEWGOOD(远古)校园网流媒体服务平台介绍
- 宏正ATEN发行全新高端式IP-Based Cat 5 KVM多电脑切换器
- jquer添加和插入元素技巧:
- 2016给自己一个目标
- Android开发中的ViewPager
- [网络通信]socket编程相关
- java序列化 与反序列化,将集合写入文本同时一个一个读出来
- Liferay 修改portal_normal.vm时乱码
- 想说爱你不容易——Oracle 10053、10046
- HugePages on Linux 64-bit
- ASM磁盘组添加磁盘(生产尽量不用)
- 节点重新启动、驱逐或 CRS 意外重启
- yii分页类CLinkPager扩展 增加显示共x页
- tableView视差滚动
- CUICatalog: Invalid asset name supplied: (null)