将数据从一个网站集获取到同一 Web 应用程序 SharePoint 2016 中的另一个网站集



我在本地使用 SharePoint 2016。我有一个 Web 应用程序,其中有 2 个网站集。 站点 1 和站点 2。 我想使用 rest 或 java 脚本或 J 查询在网站集 2 页面上显示网站集 1 列表中的数据。我的环境没有配置应用程序,所以我无法使用应用程序甚至服务器端代码。 请提出任何替代方案。

提前谢谢。

在此处共享脚本,以防有人有类似的要求。

<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>

最新更新