[javascript]비동기 통신 ajax를 이용한 동적처리

Chouettics·2021년 5월 7일
0

ajax

: ajax를 이용하기 위해서는
jquery가 필요하다

  $.ajax({
    url : url,
    type : "POST",
    data : JSON.stringify(json),
    contentType : 'application/json;charset=UTF-8',
    success: function (res) {
      	// Post 통신 성공시 로직
	// res는 RestApi로부터 받은 데이터 (여기서는 json형식)
    },
    error : fucntion (res) {
 	// 에러시의 로직
    }
});
  • data : ajax에서 보내는 데이터
  • dataType : data의 타입
  • contentType : 받아오는 데이터 타입
profile
IT Consultant & Solution Engineer

0개의 댓글