Get Current Web Logged In User of SharePoint Site in jQuery

Get Current web logged in User of a SharePoint site in jQuery:

Use the below snippet and just replace the jQuery library URL and run on you SharePoint page.

<script src="../Assets/Jquery/jquery-1.9.1.min.js"></script><script >
function getCurrentLogInUser(){
$.ajax({
    url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/currentuser",
    type: "GET",
    async:false,
    headers: { "Accept": "application/json;odata=verbose" }
}).success(function( data ){
    console.log( data );
    console.log( data.d.Title );
}).error(function(e){
    console.log( e );
});
}getCurrentLogInUser();
</script>

Output:

Comments

Popular posts from this blog

Get list item entity type full name of a SharePoint list using REST API

Get SharePoint list name by GUID