사용자 정의 헤더를 사용하여 응답 데이터에 대한 추가 정보를 제공하고 싶습니다. Dojo DataGrid의 응답에서 객체 저장소 (dojo 1.7)를 통해 jsonRest 객체에 연결하여 헤더를 가져올 수 있습니까? XHR 요청을 할 때 이것이 possible 인 것을 알지만,이 경우에는 그리드가 만들고 있습니다. Dojo DataGrid jsonrest 응답 헤더
API provides 응답 객체를 반환하는 응답 오류에 대한 이벤트
이를 사용하여on(this.grid, 'FetchError', function (response, req) {
var header = response.xhr.getAllResponseHeaders();
});
나는 성공적으로 내 사용자 지정 응답 헤더에 액세스 할 수있게되었습니다. 그러나 요청이 성공하면 응답 개체를 가져 오는 방법이없는 것 같습니다. 내가 뭔가 작업을 얻을 수 있었다 ,하지만 난 그것을 의심 : 난 그냥 응답은
aspect.after(this.grid, '_onFetchComplete', function (response, request)
{
///unable to get headers, response is the returned values
}, true);
편집 값, 후, 그러나,이 응답 개체에 대한 액세스를 허용하지 않는 측면과 undocumented 개인 이벤트 _onFetchComplete을 사용하고있다 매우 잘 설계되어 있고 더 나은 이해를 가진 사람이 더 간단한 해결책을 제시 할 수 있습니다. 객체 저장소에 반환되는 나머지 저장소에서 지연된 객체를 유지할 수 있도록 aspect를 추가했습니다. 여기에 헤더를 반환하기 위해 deffered에 새로운 함수를 추가했습니다. 그런 다음 dojo hitch를 사용하여 객체 저장소의 onFetch에 연결했습니다 (현재 범위에서 결과가 필요했기 때문에). 나에게 지저분 해 보인다.
aspect.around(restStore, "query", function (original) {
return function (method, args) {
var def = original.call(this, method, args);
def.headers = deferred1.then(function() {
var hd = def.ioArgs.xhr.getResponseHeader("myHeader");
return hd;
});
return def;
};
});
aspect.after(objectStore, 'onFetch', lang.hitch(this, function (response) {
response.headers.then(lang.hitch(this, function (evt) {
var headerResult = evt;
}));
}), true);
더 좋은 방법이 있습니까?
표준 json 스토어에서는 다음과 같이됩니다. var results = this.inherited (arguments); results.then (function() { var headers = results.ioArgs.xhr.getResponseHeader ('my-header'); }); –