I'm pulling content from a series of pages using .get() and want to append the pulled content in the order in which each page appears in an array I set. However, the aggregated page is appending items as soon as they're ready instead. How can I dictate the order in which items are appended?
function loadHTML() {
for(i = 0; i < 4; i++) {
var slug = ["slug-1", "slug-2", "slug-3", "slug-4"]
$.get('http://website.com/' + slug[i], function(data) {
var text = $(data).find(".text").html();
var title = $(data).find("#title").html();
$("#page").append("<div class='content_block'><h1>" + title + "</h1>" + text + "</div>");
});
}
};
loadHTML();