好吧,所以这是我的问题。PHP - GET url忽略linelines
我有 “page1.php中”,用下面的代码:
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<textarea id="note-textarea"></textarea>
<script>
$("#note-textarea").keyup(function() {
$("#output_div").html($(this).val());
setTimeout(function() {
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject("XMLHTTP");
}
xmlhttp.open("GET", "/upload-note?note="+$('#note-textarea').val(), true);
xmlhttp.send(null);
}, 1000);
});
</script>
</body>
</html>
和 “上传-note.php”,这应该上传textarea的内容来自 “page1.php中”,到MySQL数据库。为了演示目的,我们只是说,它将会改变文本字段的内容。
<?php
echo($_GET['note']);
?>
现在这个设置工作实际上很好,但它忽略了linebreaks。有关如何处理这些问题的任何建议?
你为什么不使用'$ .ajax'后置请求呢?这是很容易,也不要发送一个完整的textarea在你的网址.. – Jer