$.ajax({
url: url,
// HTTP 요청 방식(기본값은 'GET')
type: type,
dataType: dataType,
// true(비동기, 기본값), false(동기)
async: true,
// GET방식일때 유효
cache: false,
// ajax요청을 보내기 직전에 실행하는 콜백함수(jqXHR객체를 수정할 수 있다)
beforeSend: function(xhr, opts) {
// xhr.abort() ajax 전송 막기
// xhr.setRequestHeader
},
// ajax요청이 성공했을 경우
success: function() {},
// ajax요청이 실패했을 경우
error: function(request, status, error) {},
// error나 success Callback 함수가 수행된 후에 실행되는 함수
// try ~ catch ~ finally에서 finally와 같다
complete: function(xhr, status) {}
});
참고
https://developer.mozilla.org/ko/docs/Web/API/XMLHttpRequest
https://api.jquery.com/jquery.ajax/
https://devyj.tistory.com/1
https://opentutorials.org/course/1375/6851
https://visualize.tistory.com/402
https://m3rri-developer.tistory.com/11