I am aware there are other questions addressing the same issue, but I cannot find an answer I understand properly.
I am attempting to read an array of pages by looping through an array of page names, then using jQuery's $.get function to get the contents of the page. I believe it is due to loop closure that only the last callback of the loop fires. However, I do not understand a way around this or how to fix it, could someone please explain?
Here is the code:
function checkall2()
{
i = 0;
for(i in $servers) {
$.get("servers/" + $servers[i], function(result) {
alert(result + $servers[i]);
});
}
}