Hello everyone, I am stuck in one of the javascripts, well actually AJAX bit i guess.
In PHP i have a textarea, I am saving that into the MySQL database as it is using AJAX.
When I am reading it back, I am converting the carriage returns into
to make sure that the enter keys pressed should be displayed as it is, the following is the code:
$change = array("\r\n" => "
");
$string_message = strtr($row['document_text'], $change);
echo $string_message;
This code works fine if I am not using AJAX.
What actually is happening, once the data passes through AJAX and reaches to the php script on the server, all \r\n are converted to null. See the example below.
The text is:
line1
line2
line3
once saved in DB, even using the above replace code, the string looks like this:
line1line2line3
but before saving, i view the string using alert() function in javascript, it shows the string like this:
line1
line2
line3,
but again after reading from DB
line1line2line3
2006-07-29
20:31:38
·
2 answers
·
asked by
Manish
5