I believe that what is happening here is connected with the closure. In this loop:
for(var key in this.pages) { $.ajax({ method: 'get', url:'http://'+location.hostname+'/'+key, success: function(data) { _Ajax.pages[key] = data; } }); console.debug(this.pages); }
The key variable is actually defined outside the for loop. So, by the time you get to the callbacks, the value has probably changed. Try something like this:
http://jsfiddle.net/VHWvs/
var pages = ["a", "b", "c"]; for (var key in pages) { console.log('before: ' + key); (function (thisKey) { setTimeout(function () { console.log('after: ' + thisKey); }, 1000); })(key); }
Jason p
source share