如果您认为使用AJAX或特定库阻止您访问Web服务,则可以尝试直接使用本机JavaScript XMLHttpRequest
调用Web服务。
例如:
var verb = "GET";
var url = "http://servername/webservice_name";
var xhr = new XMLHttpRequest();
xhr.open(verb, url, true);
xhr.setRequestHeader("Content-Type","application/json");
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
myCallbackFunction(xhr.status, xhr.responseText);
}
};
xhr.send(data);
function myCallbackFunction(status, text){
// do something with the results based on the status
}
你也应该确认您的Internet Explorer设置是一样的SharePoint,因为它们是在HTML页面,在这里你能得到Web服务的工作。具体来说,您需要检查浏览器模式和安全设置。
在尝试排除网络或代码故障时,确认设置完全相同时问题仍然存在。
Sharepoint版本?该服务是否使用相同的域名? –
Sharepoint 2013在线。不,网络服务有其他域 – Dim
访问被拒绝。意味着用户在外部网站没有权限 – bresleveloper