function updateRoomsList() {
//empty the rooms list
$("#rooms").empty();
//fetch the non-joined rooms, id and name
$.get('JoinPart', {
goal: 5,
userName: $("#userName").html()
}, function (responseText) {
var i = 0;
id = "";
while (i < responseText.length) {
if (responseText.charAt(i) == '.') {
//Now we got the full Id of a room, lets add it
$.get('JoinPart', {
goal: 6,
roomId: id
}, function (responseText) {
roomName = responseText;
$("#rooms").append('<div id="room' + id + '" class="listItem"><span title="Join Room" class="joinButton">+</span><div class="listItemContent">' + roomName + '</div></div>');
});
id = "";
} else {
id = id + responseText.charAt(i);
}
i++;
}
});
}
In this Function there's a variable id, if I alert(id); after
if(responseText.charAt(i)=='.')
I get the proper value of the id calculated in the else , but when I do alert(id); inside the $.get the id is empty "" , means in the append function, the id has no value, how can I get this id to have the value outside of the $.get function ?
var id;