在下面的代码中,我想要做的是从jQuery.ajax调用获取HTTP响应代码。然后,如果代码为301(永久移动),则显示“位置”响应标题:
/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 () {
}
);
});
有人能指出我出错的地方吗?当我在Firebug中检查’jqxhr’对象时,我找不到状态码,也没有找到’Location’响应头。我在“完成”的最后一行设置断点。
非常感谢。