使用jQuery发出ajax请求时,如何访问响应头?我根据一些网站的建议尝试了下面的代码。但是xhr
对象为空。在此上下文中,我看到了一个xhr
对象,但它没有访问响应头的方法。
function SampleMethod() {
var savedThis = this;
this.invokeProcedure = function(procedurePath) {
$.ajax({
type: "GET",
url: procedurePath,
dataType: "json",
success: function(data,status,xhr) savedThis.resultSetHandler(data,status,xhr);}
});
}
this.resultSetHandler=function(data,status,xhrObj){
//Handle the result
}
this.errorHandler = function(args) {
//Handle the result
}
}
var sampleObj = new SampleMethod();
sampleObj.invokeProcedure('url');
content-length: 0 content-type: text/html; charset=UTF-8
但在Chrome Network中,我看到了更多的内容:Access-Control-Allow-Credentials: fa... ... Access-Control-Allow-Origin: https://sho... Access-Control-Max-Age: 1728... Connection: keep-alive Content-Length: 0 Content-Security-Policy: frame-ancestors 'none' Content-Type: text/html; charset=UT Refresh: 0; url=https://sec... Server: nginx/1.1... Set-Cookie: lang=ru; ...
等等。我需要Refresh,但无法获取它。 - maxkuku