1. 함수 newXMLHttpRequest()
/*********************************************************** 함수명 :newXMLHttpRequest() 처리내용 :요청객체를 생성후 반환 ***********************************************************/ // function from http://www-128.ibm.com/developerworks/kr/library/j-ajax1/index.html function newXMLHttpRequest(){ var xmlreq = false; if (window.XMLHttpRequest) { // Create XMLHttpRequest object in non-Microsoft browsers xmlreq = new XMLHttpRequest(); } else if (window.ActiveXObject) { // Create XMLHttpRequest via MS ActiveX try { // Try to create XMLHttpRequest in later versions // of Internet Explorer xmlreq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e1) { // Failed to create required ActiveXObject try { // Try version supported by older versions // of Internet Explorer xmlreq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e2) { // Unable to create an XMLHttpRequest with ActiveX xmlreq = false; } } } return xmlreq; } //GET요청 function requestGET($_url,$_query,$_req){ var myRnd = + new Date().getTime(); $_req.open("GET",$_url+"?"+$_query+"&myRnd="+myRnd,true); $_req.send(null); } //POST요청 function requestPOST($_url,$_query, $_req){ $_req.open("POST",$_url,true); $_req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); $_req.send($_query); }
'자바스크립트 > Ajax' 카테고리의 다른 글
자바스크립트 아작스 로딩바 (0) | 2012.11.10 |
---|---|
민간부문의 장애인 웹 접근성 제고 세미나 개최 (0) | 2010.06.30 |
Ajax 강좌 (0) | 2010.06.30 |