I'm trying to pull the links I need from another site and shove them into an array. It seems to be doing everything right, but the array turns out to be strange. When debugging, this is what happens:
Why is it throwing me into a new file with a single variable? I encounter this problem already in the second project, but for the first time I was sure that this was due to bubbling. This time there are clearly no mouse events and the like. Why is it throwing me into another file and debugging is interrupted? (I can’t walk the code further)
Code:
function getPostsLinksArray(homeUrl) { var url = "https://www.thesimsresource.com/downloads/browse/category/sims4/order/downloads/"; var itemLink = "", data = "", postLink = "", postLinks = []; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'document'; xhr.onload = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { itemLink = xhr.response.getElementsByClassName("item-link"); for (var i = 0; itemLink.hasOwnProperty(i); i++) { postLink = homeUrl + itemLink[i].getAttribute("data-href"); postLinks.push(postLink); } } } }; xhr.send(); console.log(postLinks[0]); 