views:

56

answers:

1

hello, i am trying to get the headers of an ajax request i made through jquery

 $.get(url, 
    function(response, textStatus, headers ) {
        console.log("Response: %o", response);
        console.log("TextStatus: %o", textStatus);
        console.log("Request: %o", headers);
    }
);

this does not seem to be working however:

the response and textstatus are printing, but the "headers" object seems to be undefined

i simply want to check if it is what i expect (content type='excel', etc) or if the response type is html, i can assume the page i was calling is an error

+1  A: 

that's because the jQuery.get() callback function doesn't have a third parameter. http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype

contagious
interesting, i guess they removed this feature.according to the API (i guess its outdated)http://api.jquery.com/jQuery.get/the callback DOES return [ callback(data, textStatus, XMLHttpRequest) ]any other ideas how to access this?
Will
it looks like that was added in 1.4 maybe? the api i linked to was the old documentation i guess. make sure you're using the most up to date version. you may want to use $.ajax and just use the success:, failure:, etc options.
contagious