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 처리를 해야한다.


댓글 없음:

댓글 쓰기

🧠💥 이탈리안 브레인롯(Italian Brainrot): 인터넷 밈의 신세계 🇮🇹

요즘 SNS에서 유행하는 이상한 말투, 이탈리아 억양, 그리고 피자 이모지 🤌🍕. 이게 다 뭔지 궁금하셨다면, 바로 이 ‘이탈리안 브레인롯(Italian Brainrot)’ 때문입니다! 중독성 있는 이 밈, 지금부터 쉽고 재밌게 알아볼게요. ...