The problem i have is with a simple ajax mail script.
I have it working fine like this:
php snippet:
if(mail($to,$subject,$message,$headers)){
echo "success";
}
And back in the ajax code its handled here :
if($.trim(data) == "success"){
// do the success stuff
}else{
// doo the fail stuff
}
My concern is that in the jquery code "trim" is not supported in all versions of explorer. So i would rather have the php return the string "success" already trimmed. But changing things to what you see below does not work as i expected, and runs the fail function in the ajax..?
Ammended php :
if(mail($to,$subject,$message,$headers)){
$success = trim("success");
echo $success;
}
Ammended Ajax :
if(data == "success"){
// do success stuff does not happen anymore
}else{
// now it always does fail stuff, so comparison is always false
}
Why is doing the trimming in the php instead of the ajax letting me down please..?