text: Q:
  
  JQuery object to PHP via ajax to send a mail()
  
  So i am trying to send an object from a jQuery function to a PHP script to send them via mail(), but my E-Mails are always empty, so i think i might not really understand how i should do it to make it properly work
  Here is the jQuery function
              function sendForm() {
  
              $surname = $('#surname').val();
              $name = $('#name').val();
              $email = $('#email').val();
              $comment = $('#q4').val();
  
              $to = 'asd@efg.de'
              $subject = 'Contact Form'
  
              $datastring = {$surname,$name,$email,$comment,$to,$subject}
  
              $.ajax({
                  url: 'send.php',
                  type: 'post', 
                  data: $datastring,
                  success: function() { 
                      alert('email sent!');
                  }
              });
              return false;
          }
  
  and here the send.php
  <?php
  $to      = $_POST[$to];
  $subject = $_POST[$subject];
  $message = $_POST[$comment];
  $headers = 'From: webmaster@example.com' . "\r\n" .
      'Reply-To: webmaster@example.com' . "\r\n" .
      'X-Mailer: PHP/' . phpversion();
  
  mail($to, $subject, $message, $headers);
  ?> 
  
  What am i missing? Thanks for the help!
  edit: I checked the $datastring and it had all the values of the form i wanted. Saved as an object
  
  A:
  
  You have to give the properties of your data object names, otherwise you will get errors:
  $datastring = {
      surname : $surname,
      name    : $name,
      email   : $email,
      comment : $comment,
      to      : 'asd@efg.de',
      subject : 'Contact Form'
  };
  
  On PHP side you get the values by this names again:
  $surname = $_POST["surname"];
  $name    = $_POST["name"];
  $email   = $_POST["email"];
  $comment = $_POST["comment"];
  $to      = $_POST["to"];
  $subject = $_POST["subject"];
  
  