if (document.querySelector('.refreshBar')) { document.querySelector('.refreshBar').addEventListener('click', async (e) => { e.preventDefault(); const feedUri = e.target.getAttribute('data-feed'); const cursor = document.querySelector('.post').getAttribute('data-cursor'); console.log(cursor); fetch('lib/asyncRequestHandler.php', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: "action=updateFeed&feed="+feedUri+"&cursor="+cursor+"&newer=true", mode: 'cors' }).then(response => response.text()) .then((data) => { const htmlNodes = new DOMParser().parseFromString(data, 'text/html'); const refreshBar = document.querySelector('.refreshBar'); refreshBar.after(...htmlNodes.querySelectorAll('.post')); }); }); }