You've captured a variable which is modified before your AJAX callbacks fire.
In a modern browser, you could use
let
to make a block-scoped copy of the loop variable inside the loop, and use that instead:
for (let i = 1; i < myTab.rows.length; i++){
let rowIndex = i;
$.ajax({
...
success: function(result){
if (result.ST != ""){
myTab.rows[rowIndex].cells[4].children[0].value = result.ST;
}
...
}
});
}
let - JavaScript | MDN[
^]
For older browsers, an immediately-executed function would accomplish the same thing:
for (var i = 1; i < myTab.rows.length; i++){
(function(rowIndex){
$.ajax({
...
success: function(result){
if (result.ST != ""){
myTab.rows[rowIndex].cells[4].children[0].value = result.ST;
}
...
}
});
})(i);
}