I have this simple code for get elements from a external source
for(var i=0; i<10; i++)
loadPage(link[i]);
function loadPage(href)
{
var ajax = new XMLHttpRequest();
ajax.open('get',href);
ajax.responseType = 'document';
ajax.onreadystatechange=function()
{
console.log(ajax.responseXML.querySelectorAll("a[href^='magnet']")[0].getAttribute("href"));
}
ajax.send();
}
but when i read the console i get only 2 or 3 result instead of 10. i think is because i can't run multiple onload. How i can fix this?