#AJAX
$.ajax({
url:"/Order.do",
type:"POST",
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
data: $('#smsResendFrm').serialize(), // 폼데이터 직렬화
success:function(data, textStatus) {
var returnParam =$.trim(data);
if(returnParam == 'sucess' ){
alert('재전송 되었습니다.');
}else{
alert("처리 도중 에러가 발생했습니다");
}
},
error : function(data) {
alert( "요청이 정상적으로 처리되지 않았습니다.
\n잠시 후 다시 시도해 주십시오" );
}
});
2. action 에서 ajax 값으로 리턴 시켜줄땐. 소스 추가
PrintWriter out = response.getWriter();
out.println("sucess");
out.flush();
#AJAX TIP
1. $('#smsResendFrm').serialize(), 폼데이터를 한꺼번에 전송하고싶은경우, 폼데이터를 직렬화해서 넘김.
2.결과를 알때는 var returnParam =$.trim(data); 공백제거를 하는것이 좋음. enter값이 넣어서 넘어오는거같음.
..물론 이경우에는..나중에 ..뭐 피..필요할지도..
3. contentType: "application/x-www-form-urlencoded; charset=UTF-8", 인코딩 값을 주고받는경우..
로컬일때만 일수도 있는데; was 상 설정을 하면 되긴하는데.. 혹시나 역시나의 경우 .. 세팅이 귀찮을때
# java 백단에서 결과값 보낼때
JSONObject output = new JSONObject();
output.put("result", "sucess");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(output.toString());
'웹 > JQUERY' 카테고리의 다른 글
[jquery] DIV (0) | 2015.03.26 |
---|---|
jquery document.ready (0) | 2015.03.19 |
[prototype][jquery] (0) | 2015.03.09 |
[JQUERY] (0) | 2015.03.09 |
jquery disabled readonly (0) | 2015.02.02 |