xmlファイルを解析するajax呼び出しがあります。asyncをfalseに設定しましたが、それでも機能しません。ajax呼び出しの前後にアラートがあり、連続して機能しているようです。誰かが私がどこで間違っているのか教えてくれませんか。これが私がやっていることのコードセグメントです
var i = 0;
var xmlLength = 0;
var arr = new Array();
alert("1");
$.ajax({
type: "GET",
url: "sample.xml",
async: false,
dataType: "xml",
success: function (xml) {
$(xml).find('CD').each(function () {
alert("2");
i = i + 1;
xmlLength += 1;
var title;
var getTo;
var artist;
var getToNode;
var $allToElements = 'TO';
var country = $(this).find('COUNTRY').text();
getTo = $(this).find('TO'); //.text();
if (getTo.length > 1) {
var $divId = "window" + i;
$('<div class="window" id="window' + i + '" />')
.append('<div class="topright" id="topright' + i + '"/>')
.append('<div class="topleft" id="topleft' + i + '"/>')
.append('<div class="bottomright" id="bottomright' + i + '"/>')
.append('<div class="bottomleft" id="bottomleft' + i + '"/>')
.appendTo('div#demo1');
var countr = $(this).find('COUNTRY').text();
$('div#topright' + i).append(countr);
$('div#topleft' + i).append('NW');
$('div#bottomleft' + i).append('SW');
$('div#bottomright' + i).append('SE');
var j = 0;
$(this).find('TO').each(function () {
var $name = $(this).text();
j += 1;
$('div#window' + i).append($('<p id="to' + i + '">').text($name));
});
} else {
var $divId = "window" + i;
$('<div class="window" id="window' + i + '" />')
.append('<div class="topright" id="topright' + i + '"/>')
.append('<div class="topleft" id="topleft' + i + '"/>')
.append('<div class="bottomright" id="bottomright' + i + '"/>')
.append('<div class="bottomleft" id="bottomleft' + i + '"/>')
.append($('<p id="to' + i + '">').text(getTo.text()))
.appendTo('div#demo1');
var countr = $(this).find('COUNTRY').text();
$('div#topright' + i).append(countr);
$('div#topleft' + i).append('NW');
$('div#bottomleft' + i).append('SW');
$('div#bottomright' + i).append('SE');
}
arr[i] = getTo;
}); //end of find
}
}); //end of ajax function
var j;
alert("3");
ありがとう!