Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7130039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:18:27+00:00 2026-05-28T11:18:27+00:00

I see quite a few different issues with the alert window and new lines.

  • 0

I see quite a few different issues with the alert window and new lines. Most are that the \n is considered a new line in PHP rather than getting sent to javascript.

In my case, the string is being outputted in a new window showing \n. I just tried actually writing \n into an alert box via jsfiddle, and that worked, so it must be my method of doing things…

Here is the string returned to console. as you can see, the \n is definitely there:

Username is required\nPassword is required\nEmail is required\nPhone is required\nCardnumber is required

However, it shows up like this:

An alert with \n instead of a new line

Why is this happening? I think it may have something to do with the data type, as it is returned from $.ajax

if (canAjax && !try_ajax) { 
    e.preventDefault();
    $.ajax({
        type: "POST", 
        url: "mobilesubmit.php",
        data: {"use_ajax": true, "formdata": $("#register_form").first().serializeArray()},
        success: function(data) {

            // This stupid thing should make new lines!
            alert(data);

            console.log(data);
        },
        error: function (request, status, error) {
            try_ajax = true;
            $("#register_form").submit();
        }
    });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:18:27+00:00Added an answer on May 28, 2026 at 11:18 am

    If your console log is showing \n rather than a new line, then it means the \ is escaped in the original string…

    Compare

    console.log(1,"\\n\\n");
    console.log(2,"\n\n");
    

    Solution

    use .replace() to swap your \n with newline characters

    console.log(3,"\\n\\n".replace(/\\n/g,"\n"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear experts, I am quite new to javascript and I often see coders use
Quite a few comments to answers in a different post, Where are the best
I've looked around for a while, tried quite a few different approaches to this
I've read quite a few different ways to tackle the problem of setting the
There are quite a few written about stub vs mocks, but I can't see
[FIXED] After trying quite a few different solutions I finally got one to work.
I didn't quite get / see what I was hoping for and maybe missed,
It's quite often to see com.* package namespace. What does 'com' mean? Thanks.
We currently have quite a few classes in a project, and each of those
I am designing an C++ app that, among other things, executes a few scripts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.