The ajax call is asynchronous, which means you're making the call, creating an event handler for when it's completed and then setting the scrollTop value before that actually happens. Try this instead...
function loadXMLDoc(sendString){
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject("Microsoft.XMLHHTP");
}
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
terminal.value += xmlhttp.responseText+'\n';
terminal.scrollTop = terminal.scrollHeight;
console.log("1: " + terminal.scrollTop);
console.log("2: " + terminal.scrollHeight);
}
}
xmlhttp.open("POST", "php/demo_get.php", true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(sendString);
}