我正在做一個$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