Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Alright,

    I have been learning a little of Ajax and I wanted to attempt a basic chat room, (really just sending/retrieving from a DB but displayed in a chat room style).

    I have a textarea which is where messages get typed into, so lets say I post the following:

    lorem

    ipsum
    When I am displaying that I would like the carriage returns to be shown too.

    I do not mind if they are replaced with <br />'s as that is what I tried.

    So what are they stored as, as I tried:
    Code:
    newstring = oldstring.replace("\n", "<br />");
    To no avail.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Can you show us the full code? It might be easier to infer why the replace didn't work then.

  4. #3
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hm

    Seeing as I was sending/retrieving to DB and using PHP I just used PHP's str_replace

    I did alert the variables in JS and the line breaks were apparent, so odd.

    Solved though, cheers

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Weird... But maybe you were storing \rs instead of \ns for some strange reason... But then, if it worked in PHP, it would have no reason not to in JS. Very strange.

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    I do not know to be honest, I done some digging and tried different variations of carriage returns and newline characters, tried them all.

    Although my Ajax object is .responseXML not responseText maybe thats why..?

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Oh. Yes. That should be a DOM object, and therefore you shouldn't be able to do that with it, I'm afraid. That certainly complicates things.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:55 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com