Skip to main content

How to get Current web logged in User of a 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:

Raju Kumar. Yadav

Comments