async function getElem(url, selector) {
return new Promise(function (success, error) {
let xhr = new XMLHttpRequest()
xhr.open('GET', 'http://waypoints/page/' + url, true);
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
let html = document.createElement('div');
html.innerHTML = xhr.responseText;
console.log(html.querySelector(selector) + ' go1');
return html.querySelector(selector);
}
}
}
})
}
async function log(d) {
return console.log(d + ' go2')
}
async function go(num) {
let i = await getElem(num + '.html', '.section')
log(i)
}
go(1)
let form = document.querySelector(".form");
form.addEventListener("click", fun)
function fun() {
console.log(true);
}