SharePoint使用jsom查询当前用户信息

前置环境:sharepoint

'use strict'; var context = SP.ClientContext.get_current(); var user = context.get_web().get_currentUser(); var web; (function () { $(document).ready(function () { getUserName(); }); function getUserName() { context.load(user); context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail); } function onGetUserNameSuccess() { $('#message').text(user.get_title()); } function onGetUserNameFail(sender, args) { alert('Error:' + args.get_message()); } })();

posted on 2015-04-20 21:52  !无名之辈  阅读(752)  评论(0编辑  收藏  举报