我有一个openID程序,当用户提交更新新密码时,它显示“X-openIDM-Reauth-Password”,其中包含我需要的旧密码重新输入。以下是openidm方面的截图。 Ajax Header请求“X-openIDM-Reauth-Password”不起作用
所以,我有我自己的用户界面,我是来自javascript ajax方面的请求与以下ajax调用。
$.ajax({
contentType: "application/json; charset=UTF-8",
datatype: 'json',
url: targetHost+"openidm/managed/user/"+userId,
xhrFields: {
withCredentials: true,
},
headers: {
"X-Requested-With":"XMLHttpRequest" ,
"X-OpenIDM-Reauth-Password": oldPassword
},
crossDomain:true,
data: JSON.stringify(data),
type: 'PATCH',
success:function(result) {
console.log("success");
swal({
title: updateSuccessMsgs.formSubmit.slogan,
text: updateSuccessMsgs.formSubmit.success,
type: "success"
}, function() {
window.location = "my-profile.html";
});
},
error:function (error){
sweetAlert(updateErrorMsgs.updateError.slogan, updateErrorMsgs.updateError.fail, "error");
console.log(error);
}
});
它会抛出我这个错误。
XMLHttpRequest cannot load http://localhost:9090/openidm/managed/user/09096425-4ff1-42d4-8a4d-3a6b5004afca. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
有人能解释我为什么吗?欣赏它。
lookup ** CORS ** - 服务器没有发送头允许客户端“访问”资源 - 注意:因为这是一个* preflight *错误,它可能仅仅是服务器不会不明白如何处理** OPTIONS **请求方法 –
您还需要在服务器上添加'Access-Control-Allow-Origin:*'标头。 –