У меня все работает:
<div id="mydiv"></div>
<script type="text/javascript">
function getMsg() {
var req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
req.open( 'GET', 'http://lookatcode.com/showjs', true );
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 204) {
document.getElementById('mydiv').appendChild(document.createTextNode("my-message_1"));
}
if (req.status == 200) {
document.getElementById('mydiv').appendChild(document.createTextNode("my-message_2"));
}
}
}
req.send(null)
}
getMsg();
</script>