I want to load the source for multiple HTML pages and parse out part of each page, then take the parsed section and append it to a div on the existing page.
I'm also adding some HTML to the parsed data, which is a link to the original page.
The $.get works, but the link to the original page always shows whatever is the last value of the pages
array. I suspect this is a a timing issue; that is, the for loop
finishes before the $.get can parse data ... or something.
var pages=["coralville.html",
"mercyHomeHealth.html",
"mercyInpatient.html",
"steindler.html",
"mercyMedicalPlaza.html",
"iowaCityTowncrest.html",
"tipton.html",
"williamsburg.html"];
var hPageName="";
for(var i=0;i<=pages.length-1;i++){
hPageName=pages[i];
$.get(hPageName,function (data) {
$(data).find(".third").each(function(){
var wPage=$(this).parent().parent().find(".oneCol").find(".hdr").html();
var nData="<div class='staffLoc'><a href='"+hPageName+"'>"+wPage+"</a></div>"+$(this).html();
$("#allPeople").append( "<div class='third'>"+nData+"</div>" );
});
});
}