Save your url
in a variable. And you can use it in the error function. Obviously the url will be same as it was supplied in the url parameter of the ajax request
var url = 'somewhere/foo';
$.ajax({
type: 'get',
url: url,
context: this,
success: this.mySuccess,
error: this.myError,
cache: false,
error: function(jqXHR, exception) {
//use url variable here
}
});
Another option can be this
$.ajax({
type: 'get',
url: 'https://google.com',
context: this,
success: this.mySuccess,
error: this.myError,
cache: false,
beforeSend: function(jqXHR, settings) {
jqXHR.url = settings.url;
},
error: function(jqXHR, exception) {
alert(jqXHR.url);
}
});