title: jquery / ajax form - serverside php but get Cross domain warning
body: <p>I'm stuck at this problem half the day and i'm totally out of options now. </p>
  
  <p>I have a form that is submitted via a click handler to a php script that is in the <strong>SAME directory</strong> BUT everytime I try to send it, i get a <strong>cross domain script warning</strong>. </p>
  
  <p>Please Help, you are my only hope ( since nobody else seem to have that problem according to google and i'm only half a hour from trowing my laptop out of the window).</p>
  
  <p>thanks for your help, </p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>POST http://mydomain/contactscript.php 500 (Internal Server   Error)jquery.js:8625 n.ajaxTransport.k.cors.a.crossDomain.sendjquery.js:8161     
  n.extend.ajaxcontact.js:12 (anonymous function)jquery.js:4430 n.event.dispatchjquery.js:4116 n.event.add.r.handle
  </code></pre>
  
  <p><strong>My Ajax Call:</strong></p>
  
  <pre><code>$('#kontaktformular button.cbp-mc-submit').click(function(event){
      event.preventDefault();
      var myForm = $("#kontaktform");
      var button = $("#kontaktform button.cbp-mc-submit");
      if($('#firstname').val() != "" &amp;&amp; $('#firstlast').val() != "" &amp;&amp; $('#email').val() != "") {
          $.ajax( {
              url: 'contactscript.php',
              type: 'POST',
              dataType: 'html',
              data: myForm.serialize(),
              beforeSend: function() {
                  // alert.fadeOut();
                  button.html('abgesendet....'); // change submit button text
              },
              success:function(result){
                  button.html('Kontaktanfrage absenden');
              }
          });
      }
      else{
  
          $('#first_name , #last_name, #email1').filter(function() { return $(this).val() == ""; }).css({'background': "#ffa5a5", 'color' : 'white'});
      }
  });
  </code></pre>
  
  <p>AJAX compiled Message (I guess?)</p>
  
  <pre><code>Remote Address:xx.xx.xx.xx.xx:80
  Request URL:http://domain/contactscript.php
  Request Method:POST
  Status Code:500 Internal Server Error
  Request Headersview source
  Accept:text/html, */*; q=0.01
  Accept-Encoding:gzip, deflate
  Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
  Cache-Control:no-cache
  Connection:keep-alive
  Content-Length:90
  Content-Type:application/x-www-form-urlencoded; charset=UTF-8
  Cookie:_ga=GA1.2.878328721.1423595127
  Host:domain.de
  Origin:http://domain.de
  Pragma:no-cache
  Referer:http://domain.de/contact.html
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2)              AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
  X-Requested-With:XMLHttpRequest
  Form Dataview sourceview URL encoded
  firstname:name1
  lastname:name2
  phone:
  email:grml@idontcare.com
  subject:
  comments:textyay
  Response Headersview source
  Connection:close
  Content-Length:0
  Content-Type:text/html
  Date:Mon, 02 Mar 2015 03:32:00 GMT
  Server:Apache/2.2.29 (Unix)
  X-Powered-By:PHP/5.3.29
  </code></pre>
  
  <p>The ContactScript</p>
  
  <pre><code>&lt;?php
  if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) ){
  if (isset($_POST['lastname'],$_POST['firstname'] ,$_POST['email']) {
  
  
  
     $firstname  =    check_input($_POST['firstname']);
     $lastname   =    check_input($_POST['lastname']);
     $email      =    check_input($_POST['email']);
     $phone      =    check_input($_POST['phone']);
     $callback   =    check_input($_POST['callback']);
     $subject    =    "Kontaktanfrage"  .check_input($_POST['subject']);
     $comments   =    check_input($_POST['comments']);
     $name    =    "$firstname $lastname";
     $message =  "NAME: $firstname $lastname  "   ."&lt;br&gt;\n";
     $message .= "TELEFONNUMMER:  $phone"   ."&lt;br&gt;\n";
     $message .= "RÜCKRUF: $callback"   ."&lt;br&gt;\n";
     $message .= "EMAIL: $email "    ."&lt;br&gt;\n";
     $message .= "BETREFF: $subject"     ."&lt;br&gt;\n";
     $message .= "NACHRICHT: " .$comments   ."&lt;br&gt;\n";  
  
  
  
    $sent = sendmail($email, $name, $subject, $message);
  
    if ($sent) {
    echo 'Message sent!';
     } else {
      echo 'Message couldn\'t sent!';
    }
   }
    else {
    echo 'All Fields are required';
    }
    return;
   }
  
  
  
  
  
  function check_input($data)
   {
      $data = trim($data);
      $data = stripslashes($data);
      $data = htmlspecialchars($data);
      return $data;
   }
  
  function sendmail($from_mail, $from_name, $subject, $message){
    $header = array();
    $header[] = "MIME-Version: 1.0";
    $header[] = "From: {$from_name}&lt;{$from_mail}&gt;";
   /* Set message content type HTML*/
    $header[] = "Content-type:text/html; charset=iso-8859-1";
    $header[] = "Content-Transfer-Encoding: 7bit";
   if( mail('info@mailaddress.de', $subject, $message, implode("\r\n",    $header)) ) return true; 
  }
  
  
  
  ?&gt;
  </code></pre>