[AJAX] STATUS 상태

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

status 는 처리후 수행결과를 알 수 있다.

<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){
                        if(httpReq.status==200){
                                alert("요청성공");
                        }else if(httpReq.status==403){
                                alert("접근거부");
                        }else if(httpReq.status==404){
                                alert("페이지없음");
                        }else if(httpReq.status==500){
                                alert("서버오류");
                        }
                }
        }
//-->
</SCRIPT>
<input type="button" value="호출" onclick="proc()">
크리에이티브 커먼즈 라이센스
Creative Commons License

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

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