How to force to work the condition in ajax?

Hi all. Tell me why it could stop working condition if(msg == 'SEND') ? In the debugger I checked, the file mail.php if successful, send back "SEND", but the script works with the condition that the received response is not "SEND", although it displays the word "SEND" when a successful send mail to $('.error-message').html("+ msg +") . On other sites the same design works without errors.

$contactform.submit(function(){
$.ajax({
 type: "POST",
 url: "/mail.php",
 data: $(this).serialize(),
 success: function(msg)
{
 if(msg == 'SEND'){
$('.error-message').hide();
$('.success-message').hide();
$contactform.hide();
 $('.form-zvonok form input').val(");
 $('.form-zvonok form textarea').val(");
 $('.success-message').html('<div class="success-message">'+ $success +'</div>');
$('.success-message').fadeIn();
}
else{
$('.success-message').hide();
$('.error-message').hide();
 $('.error-message').html('<div class="error-message">'+ msg +'</div>');
$('.error-message').fadeIn().delay(3000).fadeOut();
}
}
});
 return false;
 });

if ($_POST['form-id']=='1'){
if (!empty($_POST['name']) && !empty($_POST['phone'])){
$name=$_POST['name']; 
$phone=$_POST['phone']; 
$title=$_POST['form-name'];
$msg1=" 
Name: $name
Phone: $phone
";
mail("$adminemail", "$date $time $title", "$msg1"); 
print "SEND";
} else {
print "please Fill all fields to send message"; 
}
}
July 9th 19 at 10:12
2 answers
July 9th 19 at 10:14
There may be a gap before sending invisible.

Save the script in UTF-8 Without BOM
July 9th 19 at 10:16
The first rule of debugging - output or in the log check the value.
The second rule of debugging - if the values are correct, you have to watch the length of the answers - there may be spaces, newlines, symbol BOM, something else unprintable.

Find more questions by tags jQuery