AJAX获得与CORS定制响应头 [英] AJAX get custom response headers with CORS
问题描述
我的服务器发送自定义的报头以及响应。我得到的响应数据好了,但我不能用jQuery的 getAllResponseHeaders()访问自定义标题
或AngularJS $ HTTP
服务。我得到的是内容类型
。当我检查与DevTools或小提琴手请求响应,我可以看到被送到服务器所有自定义标题,但我不能从XHR得到他们。有什么办法来访问所有的头?
My server sends custom headers along with the response. I get the response data alright, but I can't access the custom headers with jQuery's getAllResponseHeaders()
or AngularJS $http
service. All I get is content-type
. When I inspect the request response with DevTools or fiddler, I can see all the custom headers being sent by the server, but I can't get them from xhr. Is there any way to access all the headers?
推荐答案
确定我得到这个工作在我的服务器配置加入让头后访问控制 - 揭露-头
OK I got this working after adding allowed headers in my server config Access-Control-Expose-Headers
这篇关于AJAX获得与CORS定制响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!