Form posting with AJAX?


I’m trying to use AJAX to post a “comments box” to the database. The comments box is an HTML called “discussion_comment”

function onPostComment(){
var oField = getElementByID(“discussion_comment”);
var url=“post/post_comment.asp”
var params=“comment=” + oField.value;,params);

The AJAX mechanism itself works, but I lose white space and newlines as entered by the user. For example, if I type in the following in the textarea:

this is my message.
Here is line 3!

The result as posted and stored to the database is:

I then modified like this:
var params=“comment=” + encodeURIComponent(oField.value);

In this case, the white space between words no longer collapses as it did, but newlines as entered by the user do not translate.

If I actually POST the HTML form (in a traditional sense) everything translates nicely. So what do I have to do to post the textarea via. AJAX and retain all white space and newlines as entered by the user?