Ajax and CodeMirror Textarea

I have a textarea where i get userinput, and i have another textarea where an ajax response would be dumped. Onclick of a button, the ajax code gets the userinput, sends it to a php page and is supposed to put the reply in a textarea box but instead, it creates a new textarea but doesn’t delete the old one.

AJAX:
function compile() {
var usercode = document.getElementById(“textareaa”).value;
console.log(usercode);
var response2 = document.getElementById(“serveResponse”);
var editor = CodeMirror.fromTextArea(response2);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
editor.getDoc().setValue(this.responseText);
} else {
alert(“Did’t get a reply, or something is wrong” + this.responseText);
}
};
var data = “code=” + usercode;
xhttp.open(“POST”, “test.php”, true);
xhttp.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”);
xhttp.send(data);

// Just debugging here
//response2.CodeMirror.toTextArea();
editor.setValue(“maybe processing”);
//response2.CodeMirror.toTextArea();
editor.save();
}

Never mind, Solved it.