title: PHP adding unwanted line break to ajax result
body: <p>Why is PHP adding a line break to my simple AJAX result?  This couldn't be much easier.  Am I missing something?</p>
  
  <p>Here is my JS:  </p>
  
  <pre><code>$(document).ready(function() {
      $('#inputEmail').change(function(){
          // Check to see if email exists
          var email = $('#inputEmail').val();
          //alert(email);
          $.ajax({
              url : "php/checkUserEmail.php",
              type: "POST",
              dataType: "text",
              data: {email: email},                
              success: function(data){
                  alert(data);
                  if(data === "exists"){
                      alert(data);                        
                  }                    
              },
              error: function (jqXHR, textStatus, errorThrown)
              {
                  alert("ajax error");
              }
          });              
      });
  });
  </code></pre>
  
  <p>Here is my php:</p>
  
  <pre><code>&lt;?php 
  
  include_once("db_connect.php");
  
  // Catch results sent via $.post and assigns them to php variables.
  $email = $_POST['email'];
  
  // Check to see if email exists
  $sql = "SELECT * FROM users WHERE email = '$email'";
  $conn-&gt;prepare($sql);
  $result = $conn-&gt;query($sql);
  $rowCnt = $result-&gt;num_rows;
  
  if($rowCnt == 0){
      echo trim('new');
  }else{
      echo trim('exists');
  }
  </code></pre>
  
  <p>For whatever reason, my result data string is returned as /r/nexists, rather than just exists, and thus never gets into my if block, even if I only use == to evaluate the condition.  I tried adding the trim() function as you can see without result.  Your help is much appreciated as this has taken me hours of time for a stupid if condition.</p>