Есть вот такая страничка
<html>
<head>
<title>Title</title>
</head>
<body>
<div id="ajax">
<input id="upfile" type="file" name="upfile"><br>
<textarea id="description_area"></textarea><br>
<button type="button" onclick="loadDoc()">Load Picture</button>
</div>
<button onclick="view()">Show Pre-View</button>
<div id="view">
</div>
<script src="script.js"></script>
</body>
</html>
И вот такой скрипт:
var file=document.getElementById("upfile"),
form=new FormData();
function loadDoc() {
var up_file=file.files[0];
form.append("upfile",up_file);
form.append("action","load_description_image");
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
var text=document.createTextNode('\n[img]'+this.responseText+'[/img]\n');
document.getElementById('description_area').appendChild(text);
}
};
xhttp.open("POST", "start", true);
xhttp.send(form);
}
Если нажимать на кнопку Load Picture, то строки добавляются. Но как только я пытаюсь вручную добавить какой-то текст и потом нажать на кнопку, он перестаёт добавляться. С чем это может быть связано?