无法识别访问控制允许源



我需要在SharePoint newform中使用JavaScript/jquery从外部服务器获取员工信息。 首先我写了下面的代码

function CallClientIDWebSerivce() {
var URL = "http://applicationsrv/HRMServices.asmx/GetEmployeeInfo";
alert(URL)
$.ajax({
type: "POST",
url: URL,
dataType: "xml",                     
data:"userName:"+username+",date:"+today()+",modified_by:"+username+"}" ,          
contentType: "application/xml; charset=utf-8",
success: function (response) {
alert(response);
},
failure: function (msg) {
alert('failure');
dialog.innerHTML = "Some Unknown Error Occured, Please Try Again";
}
});
}

并得到错误

XMLHttpRequest: Network Error 0x80070005, Access is denied.

我用谷歌搜索它,我发现它发生在跨源资源共享
中,所以我向 ajax 添加了Access-Control-Allow-Origin : "*",,但浏览器无法识别它并出现错误。

您不必在客户端上执行任何操作。浏览器会自动执行此操作。但是,应将共享点配置为允许对源自其他域的脚本的请求。 查看此处如何配置共享点: https://social.msdn.microsoft.com/Forums/security/en-US/8dfc2b5e-1136-45a8-9d85-73ce9c98fd06/how-to-enable-cors-on-sharepoint-online-site?forum=sharepointdevelopment

相关内容

  • 没有找到相关文章

最新更新