如何使用AD用户凭据使用.ajax调用访问跨域站点(SharePoint)

时间:2018-12-19 01:18:24

标签: javascript jquery ajax sharepoint

我需要使用.ajax调用从简单的javascript查询SharePoint列表。我需要使用具有SharePoint站点读取权限的AD用户凭据。 我正在做这样的事情,但出现很多错误。有任何建议。

function getBookingDetails(siteURL, listName, podName, currentTime) 
{ 
var filterQuery = "?$filter=(EventDate le datetime'"+ currentTime +"') and (EndDate ge datetime'"+ currentTime +"') and (PodType/PodType eq '"+ podName +"')";

    var user = "****@AD2012.***";
    var passwordtemp = "**********";

    $.ajax({
        url: siteURL + "/_api/web/lists/GetByTitle('"+ listName +"')/items" + filterQuery,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        crossDomain: true,
        beforeSend: function (xhr) {
            xhr.setRequestHeader('Authorization', make_base_auth(user, passwordtemp));
        },
        success: function (data) {
             // Doing something with data ..            
            }},
        error: function (data) {
            failure(data);
        }
    });
} // function ends ..

0 个答案:

没有答案
相关问题