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 的正确值else
,但是当我alert(id);
在$.get
id 内部做空""
时,意味着在append
函数中,id
没有值,我怎样才能让这个 id 具有 $.get 函数之外的值?