I'm trying to post this form:
<form id="the-form" enctype="multipart/form-data" >
<textarea class="form-control" name="list" id="list"></textarea>
</form>
with this script:
$.post( "/route", $('#the-form').serialize());
and debug of the script shows that JSON.stringify($('#list').val())
returns "line1\nline2\nline3"
while $('#the-form').serialize()
returns
wordlist=line1%0D%0Aline2%0D%0Aline3
.
So why does jquery.serialize encodes \n
to %0D%0A
? Is there a way to make serialize return string with %0A
EOL?
This is by design, see here:
When serializing text, encode all line breaks as CRLF pairs per the application/x-www-form-urlencoded specification.
which says:
Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
--
Is there a way to make serialize return string with %0A EOL?
None apart from removing %0D
's manually after serializing.