tags:

views:

28

answers:

1
function stateChanged(idname) { 
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById(idname).value = xmlhttp.responseText;
        }
    }
}
function openSend(php,idname) {
    stateChanged(idname);
    xmlhttp.open("GET",php,true);
    xmlhttp.send(); 
}   
function showHint() {

    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();
    } else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    openSend("time.php", "Time");
    openSend("date1.php", "Date1");
    openSend("date2.php", "Date2");
    return;
}

These two say aborted (in Firebug) and doesn't return a value. Why is that? Is it because I can't send more than 1 request?

    openSend("time.php", "Time");
    openSend("date1.php", "Date1");

If I can't, how could I achieve 3 requests with only one invocation?

+1  A: 

You need to create three XHR (XML HTTP Requests) objects, each should send one request. If you want to stick with one XHR object, you'll have to chain the requests such that after one request is finished (ready state = 4, status = whatever), the next one is fired.

Salman A