I need get employee info from external server with JavaScript/jquery in SharePoint newform. First I wrote below code
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";
}
});
}
and get error
XMLHttpRequest: Network Error 0x80070005, Access is denied.
I google it I found out it occurs for Cross-Origin Resource Sharing
so i added Access-Control-Allow-Origin : "*",
to ajax but browsers don`t recognize it and get error.
You don't have to do anything on the client. Browser does it automatically. But the Share Point should be configured to allow requests for script that originates from other domains. Look here how you can configure Share Point: https://social.msdn.microsoft.com/Forums/security/en-US/8dfc2b5e-1136-45a8-9d85-73ce9c98fd06/how-to-enable-cors-on-sharepoint-online-site?forum=sharepointdevelopment
User contributions licensed under CC BY-SA 3.0