你好!!
success: function(result){请问下,我取值要怎么取,我结果集里有10条记录,怎么循环出来呢?
追答那得看返回的结果是什么内容了?什么格式的了?
/*我没测试 你试试吧*/
追问数据怎么取呢?我这个结果集有10条,但是循环取j才是5,怎么取6-10条呢
追答我暂时能想到的就是SQL语句控制取出结果集的
分成2组数组 一组取前5条 另一组去后5条
把这两组数组在写到一个大数组中返回
剩下的 就看你怎么控制了
或者 你在等等大神回复
谢谢了,我等等看有没有好方法
$(function(){
//注释是不对的。append还是需要添加闭合标签,不然搭建的表格结构有问题
$.getJSON(
"/homeofcar/user/getjson",
function(data) {
var list = data;
//循环
$.each(list,function(i,user){
//构建行
var $tr = $("<tr></tr>");
//复选框
$tr.append('<td><input type="checkbox"/></td>');
//用户
$tr.append("<td>"+user.realname+"</td>");
//角色
var juese = '<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">';
$.each(user.listRole,function(j,role){
juese = juese + "<tr><td>"+role.rolename+"</td></tr>";
});
juese+="</table></td>";
$tr.append(juese);
/**/
// $tr.append('<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">');
// $.each(user.listRole,function(j,role){
// $tr.append("<tr><td>"+role.rolename+"</td></tr>");
// });
// $tr.append("</table></td>");
//权限
var quanxian = '<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">';
$.each(user.listRole,function(j,role){
quanxian+="<tr><td>";
$.each(role.listModule,function(k,module){
quanxian+=module.modulename;
});
quanxian+="</td></tr>";
});
quanxian+="</table></td>";
$tr.append(quanxian);
/**/
// $tr.append('<td><table cellspacing="0" cellpadding="0" border="1" style="border-collapse: collapse;border-width:0px; border-style:hidden;">');
// $.each(user.listRole,function(j,role){
// $tr.append("<tr><td>");
// $.each(role.listModule,function(k,module){
// $tr.append(" "+module.modulename);
// });
// $tr.append("</td></tr>");
// });
// $tr.append("</table></td>");
//编辑
$tr.append("<td>编辑</td>");
//构建行追加
$("#tablemax").append($tr);
});
});//getJSON
});