質問

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