0

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <!-- IE9 or superior -->
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    <title>People Picker HTML Markup</title>

    <!-- Widgets Specific CSS File -->
    <link rel="stylesheet"
          type="text/css"
          href="../Scripts/Office.Controls.css" />

    <!-- Ajax, jQuery, and utils -->
    <script src="~/Scripts/MicrosoftAjax.js"></script>
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
        // Function to retrieve a query string value.
        // For production purposes you may want to use
        //  a library to handle the query string.
        function getQueryStringParameter(paramToRetrieve) {
            var params =
                document.URL.split("?")[1].split("&");
            var strParams = "";
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve)
                    return singleParam[1];
            }
        }
    </script>

    <!-- Cross-Domain Library and Office controls runtime -->
    <script type="text/javascript">
        //Register namespace and variables used through the sample
        Type.registerNamespace("Office.Samples.PeoplePickerBasic");
        //Retrieve context tokens from the querystring
        Office.Samples.PeoplePickerBasic.appWebUrl =
            decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
        Office.Samples.PeoplePickerBasic.hostWebUrl =
            decodeURIComponent(getQueryStringParameter("SPHostUrl"));

        //Pattern to dynamically load JSOM and and the cross-domain library
        var scriptbase =
            Office.Samples.PeoplePickerBasic.hostWebUrl + "/_layouts/15/";

        //Get the cross-domain library
        $.getScript(scriptbase + "SP.RequestExecutor.js",
            //Get the Office controls runtime and
            //  continue to the createControl function
            function () {
                $.getScript("../Scripts/Office.Controls.js", createControl)
            }
        );
    </script>

    <!--People Picker -->
    <script src="../Scripts/Office.Controls.PeoplePicker.js"
            type="text/javascript">
    </script>
</head>
<body>
    Basic People Picker sample (HTML markup declaration):
    <div id="PeoplePickerDiv"
         data-office-control="Office.Controls.PeoplePicker">
    </div>

    <script type="text/javascript">
    function createControl() {
        //Initialize Controls Runtime
        Office.Controls.Runtime.initialize({
            sharePointHostUrl: Office.Samples.PeoplePickerBasic.hostWebUrl,
            appWebUrl: Office.Samples.PeoplePickerBasic.appWebUrl
        });

        //Render the widget, this must be executed after the
        //placeholder DOM is loaded
        Office.Controls.Runtime.renderAll();
    }
    </script>
</body>
</html>

我想在 SharePoint Provider-Hosted 应用程序中创建人员选择器功能。我试过这个教程:https ://msdn.microsoft.com/en-us/library/office/dn636915.aspx

我被困在这个错误上。

Invalid field or parameter url in SP.Executor.js

4

2 回答 2

0

检查您的 SP.RequestExecutor.js 是否加载成功,如果没有,您可以给出相同的路径并直接加载它,或者您可以使用以下代码获取 SP.RequestExecutor.js

var scriptbase = hostweburl + "/_layouts/15/";

$.getScript(scriptbase + "SP.Runtime.js",
    function () {
        $.getScript(scriptbase + "SP.js",
            function () { $.getScript(scriptbase + "SP.RequestExecutor.js", createControl); }
        );
    }
);

希望这能解决您的问题。

于 2016-06-08T14:58:48.853 回答
0

这解决了我的错误。感谢@Rahul 的提示

var scriptbase = hostWebUrl + "/_layouts/15/";

            $.getScript(scriptbase + "SP.Runtime.js",
                function () {
                    $.getScript(scriptbase + "SP.js",
                        function () { $.getScript(scriptbase + "SP.RequestExecutor.js",
                           $.getScript("../Scripts/Office.Controls.js", createControl));
                        }
                    );
                }
            );

于 2016-06-09T02:36:29.687 回答