Q:

Trying to show sucess message with jQuery concatenated with php echo

Im trying to do a recover password system with jQuery messages and Im having a problem.
The code below is working fine, when I click in the button to recover my username and password I get the message <p class="sucess">Email sent with your data..</p>.
But I want to put the email of the user in the message. Like this:
<p class="sucess">Email sent with your data for email@example.com!</p>
Im trying like this in my php
else {
        echo 'sucess'; //here I show the jQuery message
        echo $result['email']; //and then I want to show my $result['email']
        return; 
      }

I already try like this:
echo 'sucess'.$result['email'].'';

But I have always the same problem, Im entering here in my jQuery:
else
  {
     alert('Error in system');
}

And if I dont put this echo in $result['email'] the sucess message works fine, but when I try to echo my $result['email'] Im always entering in this jQuery condition.
Somebody there have any idea why this is happening?
My php:
   switch ($action){
    case 'recover':
        $email = $_POST['email'];

        if($email == ''){
        echo 'errorempty';
        }else{  
        $searchEmail = $pdo->prepare("SELECT * FROM admins WHERE email=:email"); 
        $searchEmail->bindValue(":email", $email);   
        $searchEmail->execute();
        $num_rows = $searchEmail->rowCount();
        $result = $searchEmail->fetch(PDO::FETCH_ASSOC);

        if($num_rows <=0 )
        {

        echo 'erroremail';
        return;
        }

        else {

        echo 'sucess';
        echo $result['email'];
        return; 
        }
        }
        break;
        default:

        echo 'Error';

    }
}

My jQuery:
$('#recover').submit(function(){
        var login = $(this).serialize() + '&action=recover';
        $.ajax({
            url: 'switch/login.php',
            data: login,
            type: 'POST',
            success: function(answer){
                if(answer== 'erroempty'){
                    $('.msg').empty().html('<p class="warning">Inform your email!</p>').fadeIn('slow');
                }
                else if (answer == 'erroemail'){
                    $('.msg').empty().html('<p class="error">Email dont exist!</p>').fadeIn('slow');

                }
                else if(answer == 'sucess'){
                    $('.msg').empty().html('<p class="sucess">Email sent with your data..</p>').fadeIn('slow');
                    window.setTimeout(function(){
                        $(location).attr('href','dashboard.php');
                 },1000);
               }
                else{
                    alert('Error in system');
                }

            },
            beforeSend: function(){
                $('.loginbox h1 img').fadeIn('fast');
            },
            complete: function(){
                $('.loginbox h1 img').fadeOut('slow');
            },
            error: function(){
                alert('Error in system');
            }

       });
        return false;
    });

A:

you can simple echo the $email like this
$email=$result["email"];
echo $email;

then in ajax success function
if(answer.email)
{
 $('.msg').empty().html('<p class="sucess">Email sent with your data..'+answer.email+'</p>').fadeIn('slow');
}

