This is my first Question on stackoverflow and i hope to get here some help. I try to write an PreCompiler in HTML. My intetion is to replace >> #include /textfile.txt << with the value of the >> textfile.txt << .
I don't know why, but i always get "undefined" as the replaced String.
<html><head>    <SCRIPT type="text/javascript">
function outp(){
    //Read String from Textarea
    var inputString = document.forms.myForm.InputArea.value;
    var replaceWord;
    var wordslenght = inputString.split(' ').length;
    var word = inputString.split(' ');
        for(var i=0; i<wordslenght;i++){
            if(word[i]== '#include'){
                // File have to be on a server (?)
                var quelle = "https://dl.dropboxusercontent.com/u/71761109/test.txt";
                var rawFile = new XMLHttpRequest();
                rawFile.open("GET", quelle, true);
                rawFile.onreadystatechange = function (){
                    if(rawFile.readyState === 4){
                        if(rawFile.status === 200 || rawFile.status == 0){
                            replaceWord= rawFile.responseText;
                            alert(replaceWord);
                        }
                    }
                }
                rawFile.send(null);
                var inputString = inputString.replace(word[i], replaceWord);
            }
        }
        //Write String in OutputArea
        document.forms.myForm.OutputArea.value = inputString;
}
</SCRIPT>
<form name="myForm" action="button">
<input type="button" name="compilier" value="GO!" onclick="outp()"></button>
  <p>Zu pruefenden Text eingeben:<br>
    <textarea name="InputArea" cols="50" rows="10"></textarea>
  </p>
  <p>Gepruefter Text:<br>
    <textarea name="OutputArea" cols="50" rows="10"></textarea>
  </p>
</form>
