尝试使用AJAX从PHP中检索值

This is what I am trying. I am trying to call a function trial with retrieves a value from a PHP for values 1 to 29 and display the result in text input boxes named T1, T2...T29.

function calculate() {
    for (var i = 1; i < 30; i++) {
        trial(i);
    }
}

function trial(i) {
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
    }
    else {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            document.getElementById('T' + i).value = xmlhttp.responseText;
        }
    }


    xmlhttp.open("GET", "MANAGER/manager.php?rownum=" + i, true);
    xmlhttp.send();

    return;
}

It is not working. Could you please suggest a solution?

The issue is that you are declaring the variable xmlhttp globally, so you are overwriting the callbacks and everything on each iteration. Use the var keyword to make it local.