title: Why are new lines not working in this javascript alert window?
body: <p>I see quite a few different issues with the alert window and new lines. Most are that the <code>\n</code> is considered a new line in PHP rather than getting sent to javascript.</p>
  
  <p>In my case, the string is being outputted in a new window showing <code>\n</code>. I just tried actually writing <code>\n</code> into an alert box via jsfiddle, and that worked, so it must be my method of doing things...</p>
  
  <p>Here is the string returned to console. as you can see, the \n is definitely there:</p>
  
  <p><code>Username is required\nPassword is required\nEmail is required\nPhone is required\nCardnumber is required</code></p>
  
  <p>However, it shows up like this:</p>
  
  <p><img src="https://i.stack.imgur.com/kD18q.png" alt="An alert with \n instead of a new line"></p>
  
  <p>Why is this happening? I think it may have something to do with the data type, as it is returned from <code>$.ajax</code></p>
  
  <pre><code>if (canAjax &amp;&amp; !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();
          }
      });
  }
  </code></pre>