I have the next js code.
var myData=[];
for(j=1;j<=Pages;j++)
{
$.ajax({
type: 'get',
url: 'link.xml'+j,
async: false,
dataType: 'xml',
success: function(data){
getData(data);
},
error: function(data){
console.log("error");
}
});
}
function getData(data){
var tmpData = {id:'' , displayName:''};
//taking the values and storing them to myData
myData.push(tmpData);
tmpData = {id:'' , displayName:'', eventsHref: []};
}
for(i=0;i<myData.length;i++)
{
$.ajax({
type: 'get',
url: 'somelink'+data[i].id,
async: false,
dataType: 'xml',
success: function(events){
getUpEvents(events);
},
error: function(events){
console.log("error");
}
});
}
function getUpEvents(events){
var tmpEvents = {displayNameEvent:[] , displayNameArtist: []};
//taking some other values and storing them to myData
myData.push(tmpEvents);
tmpEvents = {displayNameEvent:[] , displayNameArtist:[]};
}
Now to print the results from myData with a specific way.In the first line myData[0].displayName.Next lines all the myData[i].displayNameEvents that indicates to the myData[0].displayName and all the myData[i].displayNameArtist.After that it will print the next myData[1].displayName and so goes on.
Below is how i tried to print them.
for(i=0;i<myData.length;i++)
{
document.write(myData[i].displayName+"<br>");
document.write(myData[i].displayNameEvent+"<br>");
document.write(myData[i].displayNameArtist+"<br>");
}