ajax 기본 문법

ajax 기본 문법 복사, 붙여넣기 하면 끝. 



//--------------------------------------------------------------------------------------------------------------------------------------


// 문서가 준비되면

$(document).ready(function(){

// 호출 

$.ajax({

url :'./ajaxResponse.html',                         // 요청할 페이지

type : "post", //  get, post 방식

async : true , // 비동기 : true,  동기 : false 

data : JSON.stringify({"param1":"1",  "param2":"2"}),       // 전송할 데이터

dataType : "json",                  // 응답받을 데이터 타입

contentType:'application/json; charset=utf-8',         // 응답되어 받을 문서 타입설정


// 요청이 성공이면

success : function(e) {

console.log(e);


// 요청이 실패면

}, error : function(e) {

console.log(e);


// 요청이 성공이던 실패던 끝나면 요기.

}, complete: function(e){

console.log(e);

}

});

});

  

//--------------------------------------------------------------------------------------------------------------------------------------


ajax 기본 문법 복사, 붙여넣기 하면 끝 ~ !!



이 글을 공유하기

댓글

Designed by JB FACTORY