I'm not sure how to even explain this, which makes it very difficult to search on (especially because I am SURE this is an error in thinking).
I have an array of objects:
var a = [
{
url: "http://www.discusionboard.com/list-of-boards/",
name: "Discussion Board One",
threads: []
},
{url: "...", name: "...", threads: [] }
]
I am looping through these objects, downloading each page, and then trying to add the threads back to the original object.
for( var i = 0; i < a.length; i++ ) {
jQuery.get(a[i].url, function(result, status, xhr) {
/* result is list of threads separated by "[SPLIT]" */
a[i].threads = result.split("[SPLIT]")
});
}
My issue, then, is that the "i" in a[i].threads is undefined. I can't find a way to pass it into the function, and that makes me think I'm just fundamentally misunderstanding a core concept here.
Any help would be GREATLY appreciated. I'm happy to read myself, if someone could just give me an idea of what I should look for. As you can see by my title, I'm having a hard time even describing what I'm trying to do.