이 블로그 검색

2010년 9월 7일 화요일

ajax 타임아웃 발생기



xhr.open("GET", "message.html", true);

var requestTimer = setTimeout(function(){
  xhr.onreadystatechange= function(){
     if(xhr.readyState!=4){return;}//요청이 완료되지않았으면 return;
    clearTimeout(requestTimeout);  
    if(xhr.status!=200){
        //에러처리, 예를 들어 에러 메시지를 화면에 보여준다.
        return; 
     }
     $("sandbox").innerHTML="Retrieved from server...";
     $("sandbox").innerHTML+=xhr.responseText;
  };
};

xhr.send(null);

댓글 없음:

댓글 쓰기