I haven't used it myself, but according to the documentation I think the 'xhr' is used for "creating" the XMLHttpRequest object. Thus, done before the actual HTTP request is done.
I think you want the one in the 'complete' option callback. $.ajax({ complete: function(XMLHttpRequest, textStatus) { ... } }); On Jun 18, 6:58 pm, Gabriel <crazyhel...@gmail.com> wrote: > The .ajax() request has an option called 'xhr'. I am trying to grab > the filesize of a file (html) being requested with ajax. I think that > the method used with XHR is getResponseHeader. How would I implement > this into the 'xhr' option? > > I have tried several ways, but all gave me errors on Firebug, such as > that getResponseHeader was not defined. > > $.ajax({ > ... > ... > xhr: function(){ > alert( this.getResponseHeader('Content-Length'));}, > > ... > ect > > I have tried this.getResponseHeader('Content-Length'), > xhr.getResponseHeader('Content-Length'), and getResponseHeader > ('Content-Length') by itself, but no luck so far. > > If I am way off and incorrect, what would be the best way to see if > somehow the file I'm loading has changed (file size, last modified, > ect) from the last request?