After countless experiments, only this program can run normal, code paste out of pure jsom, in my experimental environment always return unknown error, for this simple task, I have been engaged for 2 days, but finally made out, using various methods, there is also the use of code.
functiongetuserinformation (loginname,propertyname) {$.ajax ({Url:appweburl+ "/_api/sp.userprofiles.peoplemanager" + "/getuserprofilepropertyfor ([email protected],propertyname= '" +proper Tyname+ "')", type:"GET", Data:"@v=" + encodeuricomponent (Logintype + loginName) + "'", headers: {"Accept": "Application/json;odata=verbose"}, Success:function(Result) {D=eval (result); $("#ecPhone"). Val (d.d.getuserprofilepropertyfor); }, Error:function(Error) {alert ("Error" +error.responsetext); }});}
In my environment, var logintype = "i:0#.w| Ad\\ ";
is actually the identity of the declaration string, the last D.d.getuserprofilepropertyfor, is the return value, I do not know why to write this.
Use JS to read user profile properties from the Add-in program in SharePoint 2013