I have a textarea for users to input comments and a button to submit using jQuery’s .post()
and JSON:
$('#submit').click(function () {
var comment = {};
comment.Author = $("#author").val();
comment.Email = $("#email").val();
comment.WebSite = $("#url").val();
comment.Body = $("#comment").val(); // textarea
$.post('/ajax/comments', comment, parseComment, 'json');
But $("#comment").val()
does not seem to preserve newlines (the input is losing newlines). How do I get this to work?