// XMLHttpRequest 생성 function newXMLHttpRequest() { var reqHttp; if (window.ActiveXObject) { // IE try { reqHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { reqHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e1) { reqHttp = null; } } } else if (window.XMLHttpRequest){ // IE 이외 try { reqHttp = new XMLHttpRequest(); } catch (e) { reqHttp = null; } } if (reqHttp == null) errorMessage(); //XMLHttpRequest 생성 실패 return reqHttp; } // 지원할 수 없는 브라우저 사용 function errorMessage() { alert("지원할 수 없는 브라우저입니다."); } // readyState와 status 체크 function openSendStatus(getPost, urlFileAppl, trueFalse, sendData ,functionname) { var xmlHttp = newXMLHttpRequest(); //XMLHttpRequest 생성 xmlHttp.open(getPost, urlFileAppl, trueFalse); //송신방법,URL,통신방법 xmlHttp.onreadystatechange = function() { //처리상태 변경 발생 if (xmlHttp.readyState == 4) { //서버 처리 완료 if (xmlHttp.status == 200) { //파일 수신 성공 eval(functionname); // mainControl(xmlHttp); //메인 처리 } else { exceptionControl(xmlHttp); //예외 처리 } } } var conType = "application/x-www-form-urlencoded; charset=UTF-8"; xmlHttp.setRequestHeader("Content-Type", conType); xmlHttp.send(sendData); //처리 데이터 송신 } // 예외 처리 (status != 200) function exceptionControl(xmlHttp) { var exceptShow = "상태 코드: " + xmlHttp.status; exceptShow += ", 비정상으로 종료되었습니다."; // alert(exceptShow); }