2011-08-03 3 views
3

도우 즈 xhrPost의 오류 처리기를 시작하려면 서버 응답을 보낼 특정 형식이 있습니까? 또는 상태 코드를 HttpServletResponse 개체의 필수 오류 코드로 설정하면됩니다.dojo xhrPost 오류 처리기의 서블릿 응답 형식

감사합니다, RR은

+0

가능한 복제본 http://stackoverflow.com/questions/5721949/what-is-considered-and-ajax-request-error-in-dojo – hugomg

답변

3

에서만 HttpServletResponse에 appropiate HTTP 상태 코드를 설정해야합니다. 400보다 크거나 같은 어떤 것이라도 XHR 객체에 의한 오류라고 생각할 것입니다.

물론 응답의 실제 콘텐츠를 출력 스트림을 통해 보내고 콘텐츠 형식을 설정할 수도 있습니다. 당신은 당신의 핸들러에서 그을 받게됩니다 : 당신은 또한 전체 XmlHttpRequest 개체입니다 ioargs.xhr에서 responseTextstatus를 얻을 수 있습니다

dojo.xhrPost({ 
    url: '/request', 
    load: function(data, ioargs) { /* ... */ }, 
    error: function(error, ioargs) { 
    // error is a Javascript Error() object, but also contains 
    // some other data filled in by Dojo 
    var content = error.responseText; // response as text 
    var status = error.status;   // status code 
    } 
}); 

.

+0

고마워. 구스타보. 이것이 제가 찾고 있던 것입니다. – rishi