So I have a loop that displays html tables from a text file onto a page, and it does so until it has used all of the available txt files that match a line from an array that i have predetermined in another part of the code.
The only problem is that while the loop is going, and all of the tables are loading, the page just sits there and looks blank. It can take a long time to load, especially on slow internet. I need to be able to load about 10 tables at a time, and then have a button at the bottom of the page that says "Click here to show more results" that causes 10 more tables to load, until all of the available tables are used.
How might I go about this? I've tried putting loops inside of loops and using a bunch of complicated if statements, but all to no avail.
Here is the loop:
arrayFinal[arrayln2]="end";
var displayNumber=0;
while(arrayFinal[displayNumber].charAt(0) != "e"){
var boxPath="camper_htmls/"+arrayFinal[displayNumber]+".txt";
boxhttp = new XMLHttpRequest();
boxhttp.open("GET",boxPath,false);
boxhttp.send(null);
var boxHTML = boxhttp.responseText;
var setDivId=document.createAttribute("id");
setDivId.value=("div_"+displayNumber);
var node = document.createElement("div");
node.setAttributeNode(setDivId);
document.getElementById("resultContainer").appendChild(node);
var divIdNumber = ("div_"+displayNumber);
document.getElementById(divIdNumber).innerHTML=boxHTML;
displayNumber++;
}