Hi, I am using JS in my website to load more content. I have buttons or input type button as my load more content.
I am worried that Google won't index the content behind the load more button because it's a button and not an anchor tag.
Here is what I am currently using ...
<div class="MORE">
<button onclick="loadMore(this, '.Memes', 'ex/more.memes.php');">Load More Content</button>
</div>
I believe there is a better way to do it. Can you help?
Also here is my JS ...
function loadMore(elm, content, ajax){
let id = document.getElementById('id').innerText;
let section = document.getElementById('section').innerText;
let subsection = document.getElementById('subsection').innerText;
let time = document.getElementById('time').innerText;
let offset = document.querySelectorAll(content).length;
elm.innerText = "Loading ...";
let formData = new FormData();
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
if(this.responseText){
document.getElementById('append-a').innerHTML += this.responseText;
impression();
elm.innerText = "Load More";
}else{
elm.innerText = "No More";
}
}
};
formData.append("id", id);
formData.append("section", section);
formData.append("subsection", subsection);
formData.append("time", time);
formData.append("offset", offset);
xhr.open('POST', ajax, true);
xhr.send(formData);
}