document.addEventListener("DOMContentLoaded", function(){
const containers=document.querySelectorAll(".jobnas-postlist-container");
const observer=new IntersectionObserver(entries=> {
entries.forEach(entry=> {
if(entry.isIntersecting){
const container=entry.target;
const settings=container.dataset.settings;
fetch(jobnasPostlist.ajaxurl, {
method: "POST",
headers: {"Content-Type": "application/x-www-form-urlencoded"},
body: "action=jobnas_load_postlist&settings=" + encodeURIComponent(settings)
})
.then(res=> res.text())
.then(html=> container.innerHTML=html);
observer.unobserve(container);
}});
}, {threshold: 0.2});
containers.forEach(c=> observer.observe(c));
});