我想从头部提取代码,这是对ajax查询的响应。在使用xhr.getAllResponseHeaders的javascript无输出中使用调试器时,我无法在dom文档中找到响应。该值不会在url本身中返回,只能在查询字符串参数中返回,所以我试图从那里获取它。这可能吗?从头部获取查询字符串参数
这里是我的谷歌的图片检查
Google Inspect Header/Query String Parameters
这里是我的代码(我一直强调,我试图抓住代码。):
$(function() {
$(".btn.getauthzcode").click(function() {
var frapptokenid = readCookie('iPlanetDirectoryPro');
$.ajax({
url: "http://[myurl]:8181/openam/oauth2/authorize?realm=/&client_id=OpenIG&response_type=code&redirect_uri=http://[myurl]:8181/openam&scope=uma_protection&save_consent=0&decision=Allow",
type: "GET",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST, GET, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, X-Token, x-token",
headers: {
"accept": "application/json",
"dataType": "jsonp",
"content-type": "application/json;odata=verbose",
"iPlanetDirectoryPro": frapptokenid,
},
success: function(data, status, xhr, url) {
debugger
console.log(url);
console.log(xhr.getAllResponseHeaders());
)},
failure: function(data) {
console.log(data);
}
});
});
});
什么是在请求中包含所有'Access-Control-Allow'属性?你认为jquery和那些人有什么关系? (提示:它忽略它们:p) –
谢谢Jaromanda。那是我试图让CORS工作。没有帮助。现在我知道为什么。 – Matt
作为一边,没有你需要发送从*客户*到“修复”的标题CORS - CORS是关于保护服务器端资源,只有服务器可以允许访问 –