Reputation: 5784
I have PHP file which at the end of sending email file I have two echo out as true or false
if(@mail($to_Email,$subject,$message,$headers))
{
echo "true";
}else{
echo "false";
}
I would like to display two alert box in case of success email sending or failure in #form-messages
so In my JavaScript I have
reqContact.done(function(data) {
if(data==true){
$("#form-messages").html('<div class="alert alert-success alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> <strong>Congrat!</strong> You Sent The Email</div>');
}
else{
$("#form-messages").html('<div class="alert alert-warning alert-dismissible" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> <strong>Warning!</strong> You Didnt Send The Email/div>');
}
});
I am able to send the email but not success to load alert box into #form-messages
. can you please let me know what i am doing wrong?
Upvotes: 0
Views: 29
Reputation: 573
Pretty sure you are returning a string not boolean.
Try...
if(data=="true")
Upvotes: 1