我正在做一个$http.get
请求到https服务,该服务有一个XML文件,它需要headers('Content-length')
知道它的大小。AngularJS - 获取标题的响应
这是我的代码:
$http({
method : "GET",
url : "https://url.com/xml_file.xml"
}).then(
function sCallback(data, status, headers, config, statusText) {
console.log(headers('Content-Length'));
}, function eCallback(data, status, headers, config, statusText) {
$log.warn(data, status, headers, config, statusText);
});
请求的结果是:"headers is not a function"
。 有没有另一种方法来获得它?
你在做这件事?你为什么期望这样做? – Amit
是的,我正在这样做。我需要这个价值来进行验证。这应该根据文档 –
工作[我如何从跨域Ajax请求访问Content-Length标头?](http://stackoverflow.com/questions/4850288/how-can-i-access- content-length-header-from-a-cross-domain-ajax-request) – Sherbrow