I have a jquery ajax statuscode function to handle a 404... another Stack Overflow answer states that in the success method, this.url gives the url for the request... however, this doesn't seem to be the case for my statusCode handler. Any ideas? Nothing that I can see in documentation about how to get the url for the request.
My ajax option object looks roughly like this (may have missed off a brace when trimming out code not relevant to this question)
;(function($) {
var defaultSettings = {
// ... other plugin specific settings
ajaxOptions:
{
cache:false,
context:$(this),
statusCode: {
404:function(xhr) {
// this line... this.url is always undefined (so is xhr.url)
$('#body').append('<div class="errordisplay">Content not found' + (this.url?': ' + this.url:'') + '</div>');
// ... do other stuff
return false;
}
}
}
}