ajax提交后如何获取Response.Headers

xjMatrix 2014-06-24 05:43:01
大家好,用ajax提交了一组数据,后端在返回时加了一个Response Header,请问前端如何获取这个Header?提交代码如下:

$.ajax({
cache: false,
type: "POST",
url: "/camera_face_register.aspx",
data: {
Person_id: document.getElementById("pid01").value,
Person_Name: document.getElementById("pname01").value,
Group_id: document.getElementById("pgid01").value,
Custom_key: document.getElementById("pkey01").value,
Photo: imgdata
},
dataType: 'multipart/form-data',
async: true,
success: function (data) {
alert(data);
// To do.
}
});

谢谢大家!
...全文
17122 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyp_1026 2016-07-29
  • 打赏
  • 举报
回复
跨域的只能获取Content-type这个怎么破?
2015god2015 2016-05-23
  • 打赏
  • 举报
回复
请问 为什么我只能从头部里得到content-type啊 其他东西都得不到
xjMatrix 2016-03-24
  • 打赏
  • 举报
回复
引用 4 楼 rendanrenjie 的回复:
请问你后台返回数据是怎么返回给前台的啊? success: function(data, textStatus, request){ alert(request.getResponseHeader('some_header')); } 就是这个,data是怎么传回来的呢
我在后台用Response.Write(data)传过来地。
SnailRen 2015-09-04
  • 打赏
  • 举报
回复
请问你后台返回数据是怎么返回给前台的啊? success: function(data, textStatus, request){ alert(request.getResponseHeader('some_header')); } 就是这个,data是怎么传回来的呢
xjMatrix 2014-06-25
  • 打赏
  • 举报
回复
引用 2 楼 u012450176 的回复:
嗯 恭喜楼主了。。
谢谢,就是你了
Justobest 2014-06-25
  • 打赏
  • 举报
回复
嗯 恭喜楼主了。。
xjMatrix 2014-06-24
  • 打赏
  • 举报
回复
已经解决了: $.ajax({ cache: false, type: "POST", url: "/camera_face_register.aspx", data: { Person_id: document.getElementById("pid01").value, Person_Name: document.getElementById("pname01").value, Group_id: document.getElementById("pgid01").value, Custom_key: document.getElementById("pkey01").value, Photo: imgdata }, dataType: 'multipart/form-data', async: true, success: function(data, textStatus, request){ alert(request.getResponseHeader('some_header')); } }); 参考:http://stackoverflow.com/questions/1557602/jquery-and-ajax-response-header 快来个人回帖吧,我好把贴子结了

52,792

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧