vrosas_03
asked on
pass linebreaks through ajax to server from a content editable div
I've used editable for my div in order to make it easy to edit the contents of a web page but when the text is sent to the server using ajax the line breaks have been removed. What's worse, I can't even detect them using a regular expression. I've tried many combinations:
alert($(this).siblings("#b ody_121"). text().rep lace(/<br> /gm, 'xxx'));
alert($(this).siblings("#b ody_121"). text().rep lace(/\n/g m, 'xxx'));
alert($(this).siblings("#b ody_121"). text().rep lace(/the/ g,"**the** "));
alert($(this).siblings("#b ody_121"). text().rep lace(/<br? \/>/g,"bre ak"));
alert($(this).siblings("#b ody_121"). text().rep lace(/\r\n /g,"**rn** *"));
alert($(this).siblings("#b ody_121"). text().rep lace(/\n\r /g,"**nr** *"));
alert($(this).siblings("#b ody_121"). text().rep lace(/\n/g ,"**nnn*** "));
alert($(this).siblings("#b ody_121"). text().rep lace(/\r/g ,"**rrr*** "));
alert($(this).siblings("#b ody_121"). text().rep lace(/<br> /g,"**rrr* **"));
alert($(this).siblings("#b ody_121"). text().rep lace(/\r\n |\r|\n/g," \n"));
alert($(this).siblings("#b ody_121"). text().rep lace(/\n\r ?/g, 'xxxxx%0D%0A'));
alert($(this).siblings("#b ody_121"). text().rep lace(/\x0A /g, '0a'));
alert($(this).siblings("#b ody_121"). text().rep lace(/\x0D /g, '0a'))
None of these works detects any line breaks. Each alert just shows the string without line breaks.
If i use firebug I can see the linebreaks being added
mmmmm
<br>
<br>
mmmmm
every time I hit enter a new linebreak is added. I can detect any other character but even this detects nothing:
alert($(this).siblings("#b ody_121"). text().rep lace(/[^m] /g, 'xxx'))
If i add any other character it detects it. such as:
mmmmmgmmm
the g will show up as:
mmmmmxxxmmm
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
alert($(this).siblings("#b
None of these works detects any line breaks. Each alert just shows the string without line breaks.
If i use firebug I can see the linebreaks being added
mmmmm
<br>
<br>
mmmmm
every time I hit enter a new linebreak is added. I can detect any other character but even this detects nothing:
alert($(this).siblings("#b
If i add any other character it detects it. such as:
mmmmmgmmm
the g will show up as:
mmmmmxxxmmm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER