我正在内部使用SharePoint 2016。我有一个Web应用程序,其中有两个网站集。 站点1和站点2。 我想使用rest或java脚本或J查询在网站集2页面上显示网站集1列表中的数据。我的环境未配置任何应用程序,因此我无法使用应用程序甚至服务器端代码。 请提出其他替代方法。
先谢谢了。
答案 0 :(得分:0)
如果有人有类似要求,请在此处共享脚本。
<script>
$(function () {
getDataFromSite1();
getDataFromSite2();
})
function getDataFromSite1() {
var url = "http://sp:12001/_api/web/lists/GetByTitle('MyList')/items";
$.ajax({
async: false,
url: url,
method: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function (data) {
console.log(data)
},
error: function (data) {
}
});
}
function getDataFromSite2() {
var url = "http://sp:12001/sites/team/_api/web/lists/GetByTitle('MyList')/items";
$.ajax({
async: false,
url: url,
method: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
},
success: function (data) {
console.log(data)
},
error: function (data) {
}
});
}
</script>