본문 바로가기
JSP/Muzi

AJAX.serialize() 시리얼라이즈 사용..

by 미눅스[멘토] 2024. 1. 27.
728x90

jsp

	for(var i = 0; i < uniqueId.length; i++){
		var id = uniqueId[i];
		var left = parseInt($("#"+id).css("left"));
		var top = parseInt($("#"+id).css("top"));
		var width = parseInt($("#"+id).css("width"));
		var height = parseInt($("#"+id).css("height"));
		var class_nm = $("#"+id).attr('class');
		var sTempValue = id+"|"+left+"|"+top+"|"+width+"|"+height; 
		$('form[name=detailForm]').append($('<input/>').attr('type','hidden').attr('name','seatIdArr').val(sTempValue));		
	}

$.ajax({
	   	type: "POST", 
	   	async: false,
	   	cache: false,
	   	url: "<c:out value='${pageContext.request.contextPath}'/>/usc/swc/adm/updateSmrtCnterSeatCrdnt.do", 
	   	data: $('form[name=detailForm]').serialize(),
		dataType: "text",
  	   	success: function(response){
  	   		seatIdArray = "";
  	   		alert('저장이 완료되었습니다.');
  	   		location.reload();
  	   	}
  	   	,error: function(response){
  	   		seatIdArray = "";
  	   		alert('저장이 실패하였습니다..');
  	   		location.reload();
  	   	}
	});

 

controller

	/**
	 * 영역 좌표정보 수정
	 */ 
	@RequestMapping(value = "/usc/swc/adm/updateSmrtCnterRelmCrdnt.do")
	public void updateSmrtCnterRelmCrdnt(
			SmrtCnterVO SmrtCnterVO,
			HttpServletResponse response, ModelMap model)
					throws Exception {
		
		//인증여부 체크
		Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
		if(isAuthenticated){
			String relmId = SmrtCnterVO.getRelmId();
				System.out.println("relmId ->" + relmId);
        		String[] relm = relmId.split("\\|");
        		
        		if(relm.length == 5){
        			SmrtCnterVO relmVO = new SmrtCnterVO();
        			relmVO.setRelmId(relm[0]);
    				relmVO.setRelmXcnts(relm[1]);
    				relmVO.setRelmYdnts(relm[2]);
//            		smrtCnterService.updateSmrtCnterRelmCrdnt(relmVO);
        		}
				
			response.setContentType("text/html;charset=UTF-8");
			response.setHeader("Cache-Control", "no-cache");
			PrintWriter out = response.getWriter();
			out.print("");
			out.flush();
			out.close();
		}      	
	}