How does JS update global variables with asynchronous AJAX?

the global variable failed to be assigned after AJAX got the return value. How to solve this problem?

The

code is as follows. Failed to assign values to words [I] and exps [I]

var index = 0;
var words = new Array();
var exps = new Array();

function addWords(shift){
    var add = new XMLHttpRequest();
    add.onreadystatechange = function(){
        if (add.readyState == 4 && add.status == 200){
            var json = eval( "(" + add.responseText + ")" );
            var i;
            for (i in json.items){
                words[i] = json.items[i].word;
                exp[i]= json.items[i].exp;
            }
        }
    }
    add.open("GET", "get.php", true);
    add.send();
}
Apr.11,2021

the first sentence in the addWords function defines var _ this=this;

then words [I], exp [I] changed to _ this.words [I], _ this.exp [I]

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ad44-2c23f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ad44-2c23f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?