PHP - GET url忽略换行符

Okay, so here's my problem.

I have "page1.php", with following code:

<!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>

And "upload-note.php", which should upload the content of the textarea from "page1.php", to a MySQL database. For demonstration-purpose, let's just say, that it's going to echo the content of the textfield instead.

<?php
    echo($_GET['note']);
?>

Now this setup works actually just fine, BUT it's ignoring linebreaks. Any suggestions on how to handle these?

The browser ignores linebreaks () in HTML documents. You have to change them with <br> tags like so..

echo nl2br($_GET['note']);

Change to POST instead of GET

xmlhttp.open("POST", "/upload-note", true);
xmlhttp.send("note="+$('#note-textarea').val());

...

echo nl2br($_POST['note']);