I modified the code here:
How to get all users From Owners Group in SharePoint 2013 for a subsite
to search for groups named "xxx Members" and their members.
To the code, I added:
function AddGroupNameRowToTable(GroupName)
{
$("#myUsersTable").append("<tr>" +
"<td colspan=2>" + GroupName + "</td>" +
"</tr>");
}
and a call to it at the end of function ExecuteOnSuccess:
GroupName = item.get_title();
if (GroupName.indexOf(" Members") >= 0)
{
//alert(GroupName);
AddGroupNameRowToTable(GroupName);
GetData(GroupName);
The problem is, I get:
Gardeners Members
Horticulturists Members
Fred Fred@xxxcom
Jed Jed@xxxcom
Lucy Lucy@xxxcom
Ron Ron@xxxcom
Tilly Tilly@xxxcom
I want to see this (spacing and dash lines for clarity):
Gardeners Members
-----------------
Fred Fred@xxxcom
Jed Jed@xxxcom
Horticulturists Members
-----------------------
Lucy Lucy@xxxcom
Ron Ron@xxxcom
Tilly Tilly@xxxcom
It looks like the functions are executing asynchronously, such that the groups get listed first.
I don't know how to get the results I want. The SP object model and coding style are new to me.
Thanks