Ajax JSON 데이터 주고 받기
프로그래밍/Spring2018. 1. 31. 13:56
function goAjax6(){
var checkValues = new Array();
$("input[name='type']:checked").each(function(){
checkValues.push($(this).val());
});
var data = {"userId": $("#userId").val(), "userPass":$("#userPass").val(), "type":checkValues };
$.ajax({
type: "POST",
url : " ",
data : JSON.stringify(data),
dataType: "json",
contentType:"application/json;charset=UTF-8",
async: false,
success : function(data, status, xhr) {
console.log(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("error= " + errorThrown);
}
});
}
/** * @param JSON 데이터 받기 * @return * @throws Exception */ @RequestMapping(value = "/goAjax6.do", method = RequestMethod.POST) @ResponseBody public MapgoAjax3(@RequestBody String param) throws Exception{ JSONObject json = JSONObject.fromObject(param); System.out.println("userId:"+json.get("userId")); System.out.println("userPass:"+json.get("userPass")); System.out.println("type:"+json.get("type")); JSONArray array = (JSONArray) json.get("type"); for(int i=0; i map = new HashMap (); map.put("AA", "1"); map.put("BB", "2"); return map; }
'프로그래밍 > Spring' 카테고리의 다른 글
| Ajax JSON Map 타입으로 넘기고 받기 (0) | 2018.01.30 |
|---|---|
| 전자정부 프레임워크 Ajax 설정 (0) | 2018.01.09 |
| Spring properties 설정방법 (0) | 2017.10.26 |