如何在angularjs $ http成功回调中获得302 HTTP响应头?

时间:2015-10-15 19:49:57

标签: javascript ajax angularjs http http-headers

我希望在API调用成功回调中获得Location标头值( 302 HTTP重定向)。我尝试了headers('Location'),但console.log()显示null。如何正确获取响应头?

响应标题:

Cache-Control:no-cache
Connection:Keep-Alive
Content-Length:324
Content-Type:text/html; charset=UTF-8
Date:Thu, 15 Oct 2015 18:51:04 GMT
Keep-Alive:timeout=5, max=100
Location:http://localhost/redirect --------------- Redirect Uri
Server:Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12

Angular成功回调:

.success(function (data, status, headers, config) {
    window.location.href = headers('Location');
})

0 个答案:

没有答案