I am making the following ajax call:
$.ajax({
type: type,
url: url,
data: data,
success: successCallback,
error: defaultFailureCallback,
dataType: 'json',
statusCode: statusCode
});
I am passing a few HTTP status codes in the statusCode parameter and the corresponding errors are handled by the respective functions. Now I want the defaultFailureCallback function to handle all the other error codes. How do I do this?
The signature of the error function in jQuery is: error(jqXHR, textStatus, errorThrown)
The problem I am facing is that there is no way to access the actual statusCode parameter inside the defaultFailureCallback function. jqXHR does not seem to contain that information. (I can get the current status from jqXHR.status)
The solution is to use
thisvariable which will contain thestatusCodevalues too.