I write a demo like this:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script type="text/javascript">
window.onload = init;
function init() {
var btn = document.getElementById('submit');
btn.onclick = function() {
var str = document.getElementById('testText').value;
alert(str);
var xmlHttp = new XMLHttpRequest();
var url = 'test.php?str=' + str;
xmlHttp.onreadystatechange = function(){
var str = xmlHttp.responseText;
document.getElementById('testText').value = str.toLocaleUpperCase();
};
xmlHttp.open('GET', url, true);
xmlHttp.send(null);
};
}
</script>
</head>
<body>
<form action="test.php" method="POST">
<textarea name="testText" id="testText" cols="30" rows="10"></textarea>
<input type="button" value="submit" id="submit">
</form>
</body>
</html>
It send a GET to server, and the php just return what it get, then js show it by uppercase(write this because of system ask me to write more detail of code)
I write some text in textarea
tag like
write some thing
write other thing
and output is
WRITE SOME THING WRITE OTHER THING
but I want to remain the blank lines, and expect output like this
WRITE SOME THING
WRITE OTHER THING
how should I do?