首页 > 解决方案 > 将数据从一个网站集获取到同一 Web 应用程序共享点 2016 中的另一个网站集

问题描述

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

提前致谢。

标签: sharepoint-2013

解决方案


Share the script here in case someone have similar requirement.

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

推荐阅读