0gam
contextType : html/text 본문
그 동안 젝슨과 모델을 이용하여 한번에 컨트롤러로 전달하였지만,
아이디 중복 확인을 만드는 중에는 id 한개만 필요하여, 바로 data로 보냈다.
(js)
var id = $("#id").val(); $.ajax({ url : "/gpim/association/check/duplication/account/", type : 'POST', data : id,contentType : "html/text", success : function(response) { if (response == "success") { $("#msg").text("사용 가능한 아이디입니다."); } else { $("#msg").text("사용 불가능한 아이디입니다."); } }, error : function(request, status, error) { } });
(controller)
"/check/duplication/account", method = RequestMethod.POST) public @ResponseBody String checkDuplicationAccount(@RequestBody String id) { Account account = accountService.findAccountById(id); if (account != null) { return "fail"; } return "success"; }
contextType : "html/text" 를 없이 보내보았다.
한글은 escape되며, 숫자는 123123"=" 콜론이 추가되는 식으로 컨트롤러에 전달되었다.
그리고 다시 contextType : "html/text" 추가하니 한글도 잘 표현되며, 추가되던 "=" 도 사라졌다.
'js, jQuery' 카테고리의 다른 글
contentType, dataType (0) | 2016.06.29 |
---|