SharePoint 2013 get current user using JavaScript

前端 未结 11 2366
挽巷
挽巷 2020-12-13 09:32

How to get current user name using JavaScript in Script Editor web part?

11条回答
  •  时光说笑
    2020-12-13 09:51

    To get current user info:

    jQuery.ajax({
        url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/currentuser",
        type: "GET",
        headers: { "Accept": "application/json;odata=verbose" }
    }).done(function( data ){
        console.log( data );
        console.log( data.d.Title );
    }).fail(function(){
        console.log( failed );
    });
    

提交回复
热议问题