In the following code, all I am trying to do is to get the HTTP response code from a jQuery.ajax call. Then, if the code is 301 (Moved Permanently), display the 'Location' response header:
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
jQuery 301 Trialfunction get_resp_status(url) {
$.ajax({
url: url,
complete: function (jqxhr, txt_status) {
console.log ("Complete: [ " + txt_status + " ] " + jqxhr);
// if (response code is 301) {
console.log ("Location: " + jqxhr.getResponseHeader("Location"));
// }
}
});
}
$(document).ready(function(){
$('a').mouseenter(
function () {
get_resp_status(this.href);
},
function () {
}
);
});
Can someone point out where I am going wrong? When I check the 'jqxhr' object in Firebug, I can't find the status code, nor the 'Location' response header. I set the breakpoint on last line of 'complete'.
Thanks much.