Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript readystate 4 responsetext状态404找不到状态文本_Javascript_Ajax_Rest_Sharepoint - Fatal编程技术网

Javascript readystate 4 responsetext状态404找不到状态文本

Javascript readystate 4 responsetext状态404找不到状态文本,javascript,ajax,rest,sharepoint,Javascript,Ajax,Rest,Sharepoint,我尝试使用REST API显示我的配置文件图片,但收到错误消息(readystate 4 responsetext status 404 status Text not found) 这是我的密码: window._spPageContextInfo = { crossDomainContextPhotosEnabled: true }; jQuery(document).ready(function () { GetCurrentUser(); fun

我尝试使用REST API显示我的配置文件图片,但收到错误消息(readystate 4 responsetext status 404 status Text not found)

这是我的密码:

window._spPageContextInfo = { crossDomainContextPhotosEnabled: true };
    jQuery(document).ready(function () {
        GetCurrentUser();

        function GetCurrentUser() {
            $.ajax({
                url: _spPageContextInfo.siteAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureURL",
                type: "GET",
                headers: {
                    "accept": "application/json;odata=verbose",
                },
                success: function (data) {
                    var userName = data.d.DisplayName;
                    var picUrl = data.d.PictureUrl;
                    $('#bild').attr('src', picUrl);
                },
                error: function (error) {
                    alert(JSON.stringify(error));
                }
            });
        }
    });

如果您能解决此问题,我将不胜感激。我假设这是一个SharePoint托管的加载项/应用程序,在这种情况下,这将是一个跨域调用,需要SP.RequestExecutor.js

此外,您可能希望尝试以下代码:

var context = SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(context);
userProfileProperties = peopleManager.getMyProperties();
context.load(userProfileProperties);
context.executeQueryAsync(success, fail);

然后,您可以在成功回调函数中获取您的配置文件图片。

首先尝试通过浏览器访问API端点,看看它是否可以访问。然后,服务器端的问题是,它无法使用您的请求。您的建议是什么?我已经测试了运行代码,并获得了指向该图片的链接,但它没有显示出来。图片被破坏你可以详细说明图片是如何被破坏的吗?请看我的回答尝试打开图像URL,看看它是否真的带来了权限错误你是说在浏览器中打开图像URL吗?当我在浏览器中实际打开URL时,将显示图像