Consider the following javascript code: details = new Array();
details[0] = new Array('pig', 'cow');
details[1] = new Array('pig', 'cow');
details[2] = new Array('pig', 'cow');
details[3] = new Array('pig', 'cow');
details[4] = new Array('pig', 'cow', 'ajax');
details[5] = new Array('pig', 'cow');
details[6] = new Array('pig', 'cow');
for(var i = 0; i < details.length; i++) {
// first alert
alert(i);
if(details[i][3] == 'ajax') {
$.get('core/data.php', {data: column}, function(data) {
load_switch(data);
// second alert
alert(i);
});
} else {
var data = $('.data tbody tr:eq(' + row + ') .' +
column).text();
load_switch(data);
// second alert
alert(i);
}
}
Alert 1 produces: 0,1,2,3,4,5,6
Alert 2 produces: 0,1,2,3,5,6,7
I can understand alert 2 being out of order or incorrect since the
loop continues to spin while the ajax call is made, but I don't
understand how the counter in the loop ever makes it to 7. Assuming
that the loop finishes cycling before the ajax call finishes,
shouldn't alert 2 produce this?
0,1,2,3,5,6,6
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ UPHPU mailing list [email protected] http://uphpu.org/mailman/listinfo/uphpu IRC: #uphpu on irc.freenode.net
