본문 바로가기

Developer/Web

Ajax 전송(get 방식)

반응형


function Get_Corp_info(Left_Value,Right_Value){

 createXMLHttpRequest(); //httpRequest 객체생성
 httpRequest.onreadystatechange = Get_Corp_info_callback;  //callback함수 

 httpRequest.open('GET', '/Map/CorpInfo/Get_Corp_info.asp?left='+ Left_Value +'&Right=' + Right_Value, true);
 
 //요청을 초기화해서 HTTP 메소드 및 URL 등을 설정하는 함수 Get방식일경우 비동기 true를 명시적으로 지정
 //POST나 GET,요청하는 URL,동기/비동기를 지정

 httpRequest.send(); //요청(데이터)을 송신하는 함수 GET에서는 send()의 인수를 쓰지 않습니다.
}

function Get_Corp_info_callback() {
 if(httpRequest.readyState == 4){ 
   if(httpRequest.status == 200) {
    var result = httpRequest.responseText;
    }
  }
}

반응형