[ajax] ajax 기본 응용

XMLHttpRequest    :
onreadystatechange       readyState            
readyState                           
responseBody                     unsigned byte      
responseStream         ADO Stream           
responseText                         
responseXML                    XML Document     
Status                               HTTP   
statusText                               

XMLHttpRequest  :
abort                                         
getAllResponseHeaders              HTTP 
getResponseHeader                        HTTP 
open                                          HTTP   ,         ,URL      (   /  )
send                                         HTTP        
setRequestHeader                          HTTP 

open(method,url,asynchronous[,user][,password])  :
method                               ,   get post
url                                     url  
asynchronous                     ,   false,  true(  )
user                                      ,   
password                             ,   

readyState      :
0   XMLHttpRequest    
1 open     
2 send       
3      ,      ,
4       

HTTP     :
200       
202      ,      
400      
404        
500        


<script language="javascript">
<!--
var xmlhttp;

function getResponse(data){
try{
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");//ie 5.0  
    }catch(e){
     try{
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//ie 5.5   
     }catch(e){
       try{
         xmlhttp = new XMLHttpRequest();//   ActiveX      
       }catch(e){}
     }
    }
var url = "i.php?id="+15;
xmlhttp.open("GET",url,false);
//xmlhttp.onreadystatechange = showMessage;//   
xmlhttp.onreadystatechange = function(){showMessage(data);};//   
xmlhttp.send(); 
}

function showMessage(data){
if(xmlhttp.readyState == 4){
   if(xmlhttp.status == 200){
    document.getElementById("Result").innerHTML = data+"======="+xmlhttp.responseText;
   }else{
    document.getElementById("Result").innerHTMl = "error";
   }
} 
}
-->
</script>

좋은 웹페이지 즐겨찾기