检索Dojo 1.6中的响应头 [英] Retrieving the response headers in Dojo 1.6
本文介绍了检索Dojo 1.6中的响应头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Dojo 1.6中检索响应头? dojo.xhr返回一个dojo.Deferred对象,当我用then()注册一个闭包时,第一个参数只包含响应体。我知道标题在ioArgs属性中,但我无法从闭包内部到达它。我接近这个错误的方式吗?
最好的问候,
CQQL
解决方案
所以这里是如何使用闭包解决的:
var result = dojo.xhr b $ bGET,
{
url:http://example.com
}
);
result.then(function(response){
console.log(result.ioArgs.xhr.getAllResponseHeaders());
});
但是对于一个干净的解决方案,ioArgs绝对应该作为响应对象的一部分传递。 >
how do I retrieve the response headers in Dojo 1.6? dojo.xhr returns a dojo.Deferred object and when I register a closure with then() the first argument contains only the response body. I know that the headers are in the ioArgs property but I cannot reach it from inside the closure. Am I approaching this in a wrong way?
Best regards, CQQL
解决方案
So here is how I solved it using a closure:
var result = dojo.xhr(
"GET",
{
url: "http://example.com"
}
);
result.then(function (response) {
console.log(result.ioArgs.xhr.getAllResponseHeaders());
});
But for a clean solution the ioArgs should definitely be passed as part of the response object.
这篇关于检索Dojo 1.6中的响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文