문제

The error callback is defined as:

Type: Function( jqXHR jqXHR, String textStatus, String errorThrown )

The complete callback is defined as:

Type: Function( jqXHR jqXHR, String textStatus )

I'd like to be able to get the errorThrown property from within my complete callback. Is it available as part of the jqXHR object?

complete is called after error but I'd like to avoid some sort of hack that saves the errorThrown value so it can be used in complete.

도움이 되었습니까?

해결책

I suppose you could attach the value to the jqXHR object in the error callback, so long as jQuery passes the same object to both callbacks:

error: function(jqXHR, textStatus, errorThrown) {
    jqXHR.errorThrown = errorThrown;
},
complete: function(jqXHR, textStatus) {
    console.log(jqXHR.errorThrown);
}

fiddle demonstrating the general concept: http://jsfiddle.net/9kQna/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top