Q:

How to retrieve boolean value from php to javascript file

is that possible to retrieve Boolean value from php to javascript? 
All I want to do is simple: Retrieve Boolean value from php variable $x into js

Should be true when emails are sent
And False when emails are not sent 

Then take that Boolean value with javascript print the appropriate message
Complete code of my work can be found here, on my other case I had opened yesterday
PHP:
if (!$mail->send()) {
   $x = false; //when email is not sent
} else {
    $x = true; //when email is sent
}

JS Pseudocode
.done(function (data) {
    if(php Boolean variable is false) { 
        ("$formText").html("Message sent");
    } else (if php Boolean variable is true) {
        ("$formText").html("Message not sent");
    }
});

A:

I am assuming you are already passing data (via AJAX) you just don't know how to encode it.
Use: json_encode()
PHP:
if (!$mail->send()) {
$x = true;

} else {
 $x = false;
}
header("Content-type: application/json");
echo json_encode(array('x'=>$x));

Javascript:
 .done(function (data) {
           if (data.x) { 
               $("#formText").html("Message sent");
           } else {
               $("#formText").html("Message not sent");
           }
        } //end function data      
  );//end done function

