I want to know that suppose you did an ajax request to a page that runs PHP code. The page outputs some data (using flush() method or otherwise) but because of a 30second timeout or some other error, the php request ends.
Now when the request ends, I want to find out about it on client side and restart the request.
i.e suppose I have something like this
xmlhttp.onreadystatechange=function(){
    if(xmlhttp.readyState==3 && xmlhttp.status==200){
    document.getElementById("A").innerHTML=xmlhttp.responseText;
    }
    else if(xmlhttp.readyState==4 && xmlhttp.status==200){
    document.getElementById("A").innerHTML=xmlhttp.responseText;
    //plus some additional code to end the process
    }
    else if(xmlhttp.status== SOMETHING /*WHAT DO I ADD HERE TO KNOW THAT THE SERVER HAS TIMED OUT OR SOMETHING SO I CAN RESTART THE XMLHTTP CYCLE */){
    //code to resend xmlhttp request.
    }
    
}