Sorry the title isn't great, it's sort of a loaded question.. What I am trying to do is load multiple pages from links on a page (they are on the same host). In my case it is a forum in the thread view, and I'd like to load the last page of posts so there's some kind of preview.
To keep it simple, my code example assumes jquery is already loaded.
Basically the code is working, however if there's many multiple requests, the page just hangs, ie - if I change the condition to intIndex < 3 or more.
$('.lastposter').each(
function (intIndex){
if(intIndex < 2){
var threadlink = $('a', this)[1].href;
var thread = $.ajax({ type: "GET", url: threadlink, async: false }).responseText;
$(this.parentNode.parentNode).attr('title', $('.post', thread).text());
}
}
);
So then my loaded question is, is there a better way to do this? I was thinking I just need some kind of pause in the loop, or maybe change it so the ajax request happens on (for example) the hover event of the row. Also, will the results be cached? If not, is there a way to make them cached or should I just leave it up to the server? I was thinking to store them as a GM variable (GM_setValue), but maybe that would get messy and or leaky.
If you have some ideas, suggestions, examples etc, I'd be happy to hear about them.