Как мы получаем доступ к заголовкам ответа, когда запускаем ajax-запрос с помощью jQuery? Я попытался использовать приведенный ниже код в соответствии с предложениями, приведенными на некоторых сайтах. Но объект 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');