[Ajax] sending textarea val with line-breaks included
Hey Guy,
I´m using the ajax function ($.ajax()) to send the value of a textarea to an php file. This works fine. But the data, which i`m sending to to the php file, is without any line-breaks.
Here is my ajax request:
- var myTextareaVal = $('#message-textarea').val();
- $.ajax({
- type: "GET",
- url: "myPhpFile.php",
- data: "text=" + myTextareaVal,
- cache: false,
- dataType: "html",
- success: function(data) {
$('.modal_content').find('.message:last').before(data);
- }
- });
So when I`m writing:
"Hello,[break]
how are you?[break]
My name is Simon"
I`m getting the data in myTextareaVal like: "Hello, how are you? My name is Simon"
I`ll hope you can help me! :-)
Monsi