Very often Ajax is used to get list items, delete them, update them etc.
I want to know how I can use ajax to get the usernames of a specific SharePoint group. (Just printing them on the console is enough for me)
This is what I've got, but it doesn't work out, because it tells me The property "results" of an undefined or null reference could not be called.
What am I doing wrong? I tried using DOM Explorer to look up the HTML as well and I was able to figure out in which div
the username was written, but don't know what to write in the code.
function getSPGroupUserInfos() {
NWF$.ajax({
url: "sites/bm/_layouts/15/people.aspx?MembershipGroupId=9",
type: "GET",
headers:
{
"Accept": "application/json;odata=verbose"
},
success: function (data, status, xhr) {
console.log("dataresults: " + data.d.results);
var dataresults = data.d.results;
for (var i = 0; i < dataresults.length; i++) {
console.log("User Title - " + dataresults[i].Title);
}
},
error: function (xhr, status, error) {
console.log("Failed");
}
});
}