title: How to get the values from a $.ajax using php
body: <p>I'm trying to use $.ajax to send some values to a php page which then sends an email,
  I can't figure out how to get the values from $.ajax in my php file,</p>
  
  <p>any help would be appreciated,</p>
  
  <pre><code>$(function() {
  
  $('form#email input[type=image]').click(function() {
  
      var name = $('form#email #name').val();
      var enq = $('form#email #enq').val();
      var dataString = 'name=' + name + '&amp;enq=' + enq;
  
      $.ajax({
          type:'POST',
          url:'email.php',
          data:dataString,
          success:function() {
              $('form#email').fadeOut();
          }
  
      });
      $('form#email')[0].reset();
      return false;                              
   });
  });
  </code></pre>
  
  <p>php file</p>
  
  <pre><code>if (isset($_POST['submit_x'])) {
  
  $name = $_POST['name'];
  $enq = $_POST['enq'];
  $name = htmlentities($name);
  $enq = htmlentities($enq);
  
  //echo $name,$enq;
  
  $to = 'amirkarimian@hotmail.co.uk';
  //$to = 'tutor@inspiretuition.co.uk'
  $subject = 'Enquiry';
  $message = $enq;
  
  mail($to,$subject,$message);
  
  if(!mail) {
      echo 'failed to send mail';
  }
  }
  </code></pre>
  
  <p>the email doesn't get sent.
  if I dont use $.ajax and submit the form normally the email get sent.</p>
  
  <p>thanks</p>