Change group path of players
//first part - define the path group
var GROUP_PATH = 'Root/first_group/Second_group';
//second part - retrieve the token
$.post({
dataType: 'json',
contentType: 'application/json; charset=utf-8',
url: SERVER_URL + 'GetToken',
data: JSON.stringify({ "Login": Login, "Password": Password }),
success: function (data) {
if (data.Status == 'SUCCESS') {
//third part - retrieve the players
$.post({
dataType: 'json',
contentType: 'application/json; charset=utf-8',
headers: { 'Token': Token },
url: SERVER_URL + 'GetPlayers',
success: function (data) {
if (data.Status == 'SUCCESS') {
//fourth part - change the players group path
for (var i = 0; i < data.PlayerList.length; i++) {
data.PlayerList[i].GroupPath = GROUP_PATH;
}
//fifth part - change the players in server
$.post({
dataType: 'json',
contentType: 'application/json; charset=utf-8',
headers: { 'Token': Token },
url: SERVER_URL + 'SetPlayers',
data: JSON.stringify({ "PlayerList": data.PlayerList }),
success: function (data) {
if (data.Status = = 'SUCCESS') {
console.log('success');
}
}
})
}
}
})
}
}
})