Jquery正确发送headers值,Django后台request.Meta取值
jquery发送请求
$.ajax({
method: "POST",
headers: {
"Auth_xxx": "yes"
},
data: {},
url: "",
success: function (response) {
console.log("response data", response);
}
})
django request.META始终取不到值
request.META.get("HTTP_AUTH_XXX", "")
改正
# jquery发请求参数不要带下划线"_"
headers: {
"Auth_xxx": "yes"
},
# 修改为
headers: {
"Authxxx": "yes"
},
# request.META.get("HTTP_AUTHXXX", "")
前提是跨域部分要打开