killboy Posted March 27, 2008 Share Posted March 27, 2008 How can I send the data of the xmlHttp.open through the post method: xmlHttp.open("POST",url,true); The thing is that I'm trying to get a text from a textarea, and when I write a new line, everything gets together; I mean,if I write Hi there.How's it going The message appears Hi there.How's it going I think that sending this message through the Post method, the xmlHttp.responseText can be viewed correctly.Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 27, 2008 Share Posted March 27, 2008 Theres a post example here:http://www.captain.at/howto-ajax-form-post-request.phpKeep in mind that HTML does not show line breaks, it shows them as a space. If you want a line break to show in HTML markup you need to use a <br> tag. You can replace the newline characters with br tags if you want to. Link to comment Share on other sites More sharing options...
killboy Posted March 27, 2008 Author Share Posted March 27, 2008 Theres a post example here:http://www.captain.at/howto-ajax-form-post-request.phpKeep in mind that HTML does not show line breaks, it shows them as a space. If you want a line break to show in HTML markup you need to use a <br> tag. You can replace the newline characters with br tags if you want to.Thanks for the link dude.How can I use the <br> tag? I mean, the text is caught from a textarea.Edit:I made it work. That link really helped. The <br> tags got them with the nl2br() function.Thanks for the help. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 28, 2008 Share Posted March 28, 2008 nl2br works for PHP. If you want to convert it with Javascript you can use a regular expression, or I typically just split and join.txt = new String(document.getElementById("textfield").value);txt = txt.split("\n").join("<br>"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.