[AJAX] readystate 프로퍼티

[■Web Programing/OO JavaScript OO]
[펌] http://harogipro.tistory.com/63

응답에 의해 호출된 함수에 적용
XMLHttpRequest 의 상태를 표시할 수 있다.

<SCRIPT LANGUAGE="JavaScript">
<!--
        function proc(){
                httpReq = getXMLHttpRequest();
                httpReq.onreadystatechange = hey ;
                httpReq.open("GET", "test.php", true);
                httpReq.send(null);
        }

        function hey(){
                if(httpReq.readystate==0){
                        alert("open매소드 호출되지 않음");
                }else if(httpReq.readystate==1){
                        alert("send 매소드가 호출 되지 않는 상태");
                }else if(httpReq.readystate==2){
                        alert("status 와 헤더는 도착하지 않은 상태");
                }else if(httpReq.readystate==3){
                        alert("데이터 일부를 받은  상태");
                }else if(httpReq.readystate==4){
                        alert("데이터전송 완료");
                }
        }
//-->
</SCRIPT>
<input type="button" value="호출" onclick="proc()">
크리에이티브 커먼즈 라이센스
Creative Commons License

이 글의 트랙백 주소 :: http://munduki.tomeii.com/darkhorse/trackback/201

::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::