title: "\r\n\" in alert for jquery ajax html
body: <p>I have an ajax request that looks like this</p>
  
  <pre><code>$(document).ready(function() {
      $(document).on('click', '#submit', function() {
          var UserName = $('#username').val();
          var PassWord = $('#password').val();
          console.log(UserName);
          $.ajax({
              type: 'POST',
              url: 'ajax/Login.php',
              dataType: "text",
              data: {
                  username: UserName,
                  password: PassWord
              },
              success: function(data) {
                  alert(JSON.stringify(data));
                  window.location='pages/mainpage.php';
              },
              error: function(data) {
                  alert('Login Error');
                  //window.location='../index.php';
              }
          });
      });
  });
  </code></pre>
  
  <p>and my php is like this</p>
  
  <pre><code>$username = mysql_real_escape_string($_POST['username']);
  $password = mysql_real_escape_string($_POST['password']);
  
  if (isset($username)) {
      $stmt = $dbh-&gt;prepare("SELECT * FROM userlist_tbl WHERE username = ? ");
      $stmt-&gt;bindValue(1, $username);
      $stmt-&gt;execute();
      $selected_row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
      if ($selected_row['username'] === $username) {
          if ($selected_row['password'] === $password) {
              $_SESSION['login_user'] = $username;
              echo "Welcome ".$username;
          }else{
      echo "Password incorrect";
  }
      }
  }else{
      echo "Username is empty";
  }
  </code></pre>
  
  <p>When i dont put anything in username i am expecting that the alert will be <code>Username is empty</code> same as when password is empty alert should be <code>Password incorrect</code> but i am getting <code>"\r\n\"</code> but if put some in username like <code>John</code> it will alert <code>Welcome John"\r\n\"</code> why is this happening?how to make it alert <code>Username is empty</code> when username is empty same with password?any idea is accepted..</p>