2017년 5월 22일 월요일

jQuery ajax contentType


  • application/x-www-form-urlencoded
key-value 형태(?key=value&key=value...)로 전송된다. 
$.ajax({
       url: "",
       type: "post",
       data: {},
       contentType: "application/x-www-form-urlencoded;charset=UTF-8",
       success: function(data) {
     
       }
}); 
jquery js파일에 default 로 contentType이
application/x-www-form-urlencoded; charset=UTF-8 로 정의되어 있기 때문에 
contentType 은 생략해도 된다.
  
  • application/json
$.ajax({
       url: "",
       type: "post",
       data: JSON.stringify(data),
       contentType: "application/json",
       success: function(data) {
     
       }
}); 
json형태로 전송된다. 
data는 반드시 Stringify 처리를 해야한다.


댓글 없음:

댓글 쓰기

스프링 빈 등록 순서 오류 시 @PostConstruct 사용

  스프링 xml 설정에서 등록할 빈을 명시적으로 지정한 것과 <context:component-scan>와 혼용해서 사용한  경우 빈등록 순서 오류가 발생 할 수도 있습니다. 여러가지 방법이 있지만, 그 중에서 @PostConstruct ...