I have a jquery ajax statuscode function to handle 404 ... another answer claims that in the success method this.url gives the url for the request ... however this does not seem to be for my statusCode handler. Any ideas? Nothing I can see in the documentation on how to get the url for the request.
My ajax options object looks something like this (maybe I missed the bracket when I cut out code that wasn’t related 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; } } } }
source share