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++;
}
});
}
この関数には変数がありますid
。alert(id);
if(responseText.charAt(i)=='.')
で計算されたIDの適切な値を取得しますが、IDの内部でelse
実行すると、IDは空になります。つまり、関数では、に値がありません。このIDを取得して、$。get関数の外部の値を取得するにはどうすればよいですか。 ?alert(id);
$.get
""
append
id