JSON(2)
-
[ Javascript ] Form.serialize를 json형식으로 변환하기
jQuery.fn.serializeObject = function() { var obj = null; try { if (this[0].tagName && this[0].tagName.toUpperCase() == "FORM") { var arr = this.serializeArray(); if (arr) { obj = {}; jQuery.each(arr, function() { obj[this.name] = this.value; }); }//if ( arr ) { } } catch (e) { alert(e.message); } finally { } return obj; }; 출처: https://cofs.tistory.com/184 [CofS] 이렇게 공통으로 쓰는 함수를 만들고 var data = { ..
2020.05.28 -
[ Ajax ] JAVA Controller에서 json 형식으로 데이터 가져오기
Ajax 부분 $.ajax({ type: "POST", url: url, data: data, dataType: 'json', success: function(data){ data.키값; }, error: function(request, status, error){ alert(request.status + "#" + request.message + "#" + error); } }) Controller 부분 @RequestMapping(url) @ResponseBody public String functionName(...)throws Exception{ ... HashMap hashMap = new HashMap(); hashMap.put("키값", 값); return JSONObject.fromObje..
2019.10.28