티스토리 뷰

js

[jQuery] ajax method option

나뜨루다 2021. 4. 1. 17:26
728x90
종류 설명
success  ajax통신이 정상적으로 이루어지면 이벤트 헨들러 실행
 success : function(result){ }
error  통신에 문제가 발생했을 때 함수 실행
 error:function(request,status,error){ }
type

 데이터를 전송할 방식 설정
 type: "post", / type : "get",
url
 데이터를 전송할 페이지를 설정 
 url : "/url",

data
 서버로 전송할 데이터를 지정
 data: data,  
timeout   응답대기시간 
 timeout : 5000,  
beforeSend  ajax 요청하기전에 실행되는 함수
 beforeSend: function() { }
contentType

 서버로 전송할 데이터의 content-type 설정
 contentType:"application/json",
complete

 ajax가 완료되었을때 함수를 실행 하는 이벤트 헨들러 
 complete: function(){ }
dataType

 "xml": XML 문서
 "html": HTML을 텍스트 데이터
 "script": JavaScript 코드
 "json": JSON 형식 데이터
 "text": 일반 텍스트
 dataType : "json",

async
 통신을 동기 또는 비동기 방식으로 설정하는 옵션
 async: true  (기본값)  / async: false

cache
 요청한 페이지를 인터넷에 저장할지 여부 설정 
 cache: true (기본값)  / cache: false