jquery ajax: headers seem to not be working
-
23-09-2019 - |
Question
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
Solution
that's because the jQuery.get() callback function doesn't have a third parameter. http://docs.jquery.com/Ajax/jQuery.get#urldatacallbacktype
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow