javascript - JQUERY response not working -


i have ajax sends email information, , responds sent or notsent, problem dont know why if after .done ajax should if respond "sent" according inspector respond sent goes else in if sention, , have no idea why, email sent , cant understand why goes else.

my jquery this:

function send() {     var nom = $('#name').val();     var ape = $('#lastname').val();     var occ = $('#occupation').val();     var dep = $('#department').val();     var dob = $('#datob').val();     var bdp = $('#place').val();     var add = $('#address').val();     var cid = $('#cidnumber').val();     var pho = $('#phone').val();     var pem = $('#mail').val();     var sta = $('#station').val();     if(bdp == '' || add == '' || cid == '' || pho == '' || pem == '')     {         swal("ooops!", "all information must filled, please check!.", "error");     }     else     {         $('#mymodalemail').modal('toggle');         $.ajax({             url: 'accionesphp.php',             type: 'post',             data: {funcion:'sendidmail',name:nom,lastname:ape,occupation:occ,department:dep,dob:dob,place:bdp,address:add,companyid:cid,phone:pho,mail:pem,station:sta}         })          .done(function(respuesta){             if(respuesta == "sent")             {                 $('#mymodalemail').modal('hide');                 swal("success!", "your card request has been sent successfuly.", "success");                 loaddata();             }             else             {                 swal("ooops!", "this embarrasing, have proble try later, error!.", "error");             }         });     } } 

and php this:

$name = $_post['name'];         $lastname = $_post['lastname'];         $occupation = $_post['occupation'];         $department = $_post['department'];         $dob = $_post['dob'];         $place = $_post['place'];         $address = $_post['address'];         $companyid = $_post['companyid'];         $phone = $_post['phone'];         $mail = $_post['mail'];         $station = $_post['station'];         //envio de mail para david wing          $mensaje = '<html>';          $mensaje .= '<body>';         $mensaje .= '<h3> new company identification card request </h3>';         $mensaje .= '<div><p> information card request below:</p>';         $mensaje .= '<label>name</label>';         $mensaje .= '<input type="text" value="'. $name .'" disabled><br<br>';         $mensaje .= '<label>last name</label>';         $mensaje .= '<input type="text" value="'. $lastname .'" disabled><br<br>';         $mensaje .= '<label>occupation</label>';         $mensaje .= '<input type="text" value="'. $occupation .'" disabled><br<br>';          $mensaje .= '<label>depatment</label>';         $mensaje .= '<input type="text" value="'. $department .'" disabled><br<br>';          $mensaje .= '<label>date of birth</label>';         $mensaje .= '<input type="text" value="'. $dob .'" disabled><br<br>';         $mensaje .= '<label>birth place</label>';         $mensaje .= '<input type="text" value="'. $place .'" disabled><br<br>';         $mensaje .= '<label>address</label>';         $mensaje .= '<input type="text" value="'. $address .'" disabled><br<br>';         $mensaje .= '<label>company id</label>';         $mensaje .= '<input type="text" value="'. $companyid .'" disabled><br<br>';         $mensaje .= '<label>phone</label>';         $mensaje .= '<input type="text" value="'. $phone .'" disabled><br<br>';         $mensaje .= '<label>personal e-mail</label>';         $mensaje .= '<input type="text" value="'. $mail .'" disabled><br<br>';         $mensaje .= '<label>station</label>';         $mensaje .= '<input type="text" value="'. $station .'" disabled><br<br>';         $mensaje .= '</body> </html>';          $para = 'gjmm1711@gmail.com';         $titulo = 'new company identification card request';         $cabeceras = 'mime-version: 1.0' . "\r\n";         $cabeceras .= 'content-type: text/html; charset=iso-8859-1' . "\r\n";         $cabeceras .='from: webmaster@example.com' . "\r\n" .                     'reply-to: webmaster@example.com' . "\r\n" .                     'x-mailer: php/' . phpversion();          if(mail($para, $titulo, $mensaje, $cabeceras))         {             print "sent";         }         else         {             print "notsent";         }          break; 

yes, email sent, 'respuesta' data php should "sent" or "notsent" comes if (mail ()) if it's true returns "sent" working according inspector "sent" answer still when if (respuesta=="sent") something

else something

idk why go else if answer php "sent"


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -