1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
var files = ['file.xml','file2.xml'] // 2 fichiers xml
var xmlResult;
var temp ={};
$.each(files, function(index,value)
{
$.ajax({
url: value,
dataType: "xml",
cache: true,
async: false, success: function(xmlResponse)
{
data = $( "desc", xmlResponse ).map(function()
{
return {
label: $( "label", this ).text(),
lien: $( "lien", this ).text()
};
}).get();
temp += data;
//temp.push(data); // ne marche pas
//temp = $.merge(temp,data ) // ne marche pas
console.dir(temp);
if (index == files.length-1)
{
xmlResult += temp;
//xmlResult = $.merge(temp,data ) // ne marche pas non plus
temp = null;
console.dir(temp);
}
}
});
}); |
Partager