加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax数据提交 遍历显示例子

发布时间:2020-12-16 02:05:41 所属栏目:百科 来源:网络整理
导读:tddiv class="button"div class="buttonContent"button class="saveAssPersonnelUser"保存联系人/button/div/div/td //常用联系人添加 $(".saveAssPersonnelUser").click(function(){ var org3_ids=$("#org3_ids").val(); var user_id=$("#user_id").val();

<td><div class="button"><div class="buttonContent"><button class="saveAssPersonnelUser">保存联系人</button></div></div></td>

//常用联系人添加
$(".saveAssPersonnelUser").click(function(){
var org3_ids=$("#org3_ids").val();
var user_id=$("#user_id").val();
jQuery.ajax({
type: 'POST',
dataType:'json',//设置为json 类型后返回数据不需要 再次转换;
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
url: '${contextPath}/wzoa/associatedpersonnel/save?org3_ids='+org3_ids+'&user_id='+user_id,
error: function() {
alertMsg.error('联系人添加失败!');
},
success: function(data) {
$("#tbody_index_html").html("");
var tbody_index_html="";
for(var p in data){//for循环直接遍历数据
tbody_index_html+="<tr id='personRoleRow_"+data[p].id+"'>";
tbody_index_html+="<td>"+(parseInt(p)+1)+"</td>";
tbody_index_html+="<td>"+data[p].recipient_name+"</td>";
tbody_index_html+="<td>"+data[p].organization_name+"</td>";
tbody_index_html+="<td>"+data[p].recipient_dept_name+"</td>";
tbody_index_html+="<td>"+data[p].post+"</td>";
tbody_index_html+="<td>"+data[p].posttype+"</td>";
tbody_index_html+="<td>"+data[p].direct_leadership=='00'?'否':'是'+"</td>";
tbody_index_html+="<td>";
tbody_index_html+="<div class='button'><div class='buttonContent'><button id='submit_"+data[p].id+"' class='assPersonnelUser'>移除</button></div></div>";
tbody_index_html+="<div class='button' style='margin-left: 10px;'><div class='buttonContent'><button id='update_"+data[p].id+"' class='updateAssPersonnelUser'>设置/取消(直接领导)</button></div></div>";
tbody_index_html+="</td>";
tbody_index_html+="</tr>";
}
$("#tbody_index_html").html(tbody_index_html);
}
});
});

@RequiresPermissions("AssociatedPersonnel:save")
@RequestMapping(value = "/save")
public @ResponseBody
Object save(HttpServletRequest request,@RequestParam(value = "org3_ids") String org3_ids,
@RequestParam(value = "user_id") int user_id) {
try{//保存基本信息附件信息
associatedPersonnelService.save(request,user_id,org3_ids);
//关联人员列表
Map<String,Object> condition = new HashMap<String,Object>();
condition.put("personnel_id",user_id);
List<Map<String,Object>> personnelList = associatedPersonnelService.getAssociatedPersonnelList(condition);
return JSON.toJSON(personnelList);//返回json格式数据 }catch(Exception e){ log.error("{}",e); return AjaxObject.newError("保存信息失败!").toString(); } }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读