Javascript 如何在SharePoint托管的应用程序(SharePoint Online)中使用$.ajax调用外部restful
正如标题所说,我在从SharePoint内部调用外部restful服务时遇到问题Javascript 如何在SharePoint托管的应用程序(SharePoint Online)中使用$.ajax调用外部restful,javascript,rest,jquery,sharepoint,Javascript,Rest,Jquery,Sharepoint,正如标题所说,我在从SharePoint内部调用外部restful服务时遇到问题 'use strict'; var context = SP.ClientContext.get_current(); var user = context.get_web().get_currentUser(); // This code runs when the DOM is ready and creates a context object which is needed to use the Sha
'use strict';
var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
getUserName();
$.ajax({
dataType: "jsonp",
url: ' http://ip.jsontest.com/',
success: function (a, b, c) {
alert(a);
},
error: function (a, b, c) {
}
});
});
...
这将返回拒绝访问。我一直在周而复始地想弄清楚如何从浏览器中拨打外部电话
这个调用不需要在jQuery中进行,如果有更好的方法,比如使用客户端对象模型,那么我愿意接受任何建议。这是因为您是从https(sharepoint online)调用http webservice。将您的Web服务转换为https。此URL在您的整个网络中都可以访问吗?不确定,这可能是问题所在。由于它是SharePoint online,我怀疑是SharePoint阻止了它。我正在考虑也许SharePoint托管可能不是托管应用程序的方式-我目前正在研究自动托管应用程序,并使用Azure。我知道我可以从Azure访问任何站点。