2014-01-17 3 views
4

나는 그것은 시대에 뒤 떨어진 현대적인 브라우저와 숨겨진 iframe을 업로드에서 XHR 파일 업로드를 사용하는 https://github.com/blueimp/jQuery-File-UploadjQuery를 파일 업로드 플러그인 - <10

(8,9)를 사용하고 IE에서 발사하지 콜백 실패.

서버는 파일 유효성 검사가 실패 할 때 4xx 상태 코드 (오류/실패)를 반환합니다. 나는 4XX 상태 코드를 보낼 때

$('#fileupload').fileupload({ 
    url: url, 
    dataType: 'json', 
    done: function (e, data) { 
     console.log("done") 
    }, 
    fail: function (e, data) { 
     console.log("fail") 
    } 
}) 

그러나 시대에 뒤 떨어진 사람에서 수행 콜백도라고합니다. 실패 콜백 ( https://github.com/blueimp/jQuery-File-Upload/wiki/Options#fail)을 호출하고 응답 본문 또는 상태 코드를 읽을 수있는 방법이 있습니까?

파일을 업로드 할 때 숨겨진 iframe 메소드로 처리해야 할 수도 있지만 문서에서 특정 항목을 찾을 수 없습니다.

+0

을 확인해야합니다. – Fractaliste

+0

알았어, 그랬어 : https://github.com/blueimp/jQuery-File-Upload/issues/2887 – Hans

답변

4

난 당신이 버그 추적기에보고해야 Frequently Asked Questions

// By default, the iFrame Transport handles all responses as success, 
// so we override the iFrame to JSON converter to handle error responses: 

$.ajaxSetup({ 
    converters: { 
    'iframe json': function (iframe) { 
     var result = iframe && $.parseJSON($(iframe[0].body).text()); 
     if (result.error) { 
      // Handling JSON responses with error property: 
      // {"error": "Upload failed"} 
      throw result.error; 
     } 
     return result; 
    } 
    } 
}); 
+0

새로운 버전의 Chrome에서도 'forceIframeTransport : true'옵션을 사용할 때 작동하지 않는 것으로 보입니다. . https://github.com/blueimp/jQuery-File-Upload/wiki/Options#forceiframetransport – GreenRaccoon23

관련 문제