title: Send cross domain request with post method
body: <p>How to send cross domain request from Javascript with Post method to Php file with large request data?</p>
  
  <p>I have tried with $.ajax , $.post but have same issue as alerting POST failed.</p>
  
  <p>Here is my HTML file[call.html] with Javascript at desktop::</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/
  libs/jquery/1.3.0/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;script type="text/javascript"&gt;
  $.ajax({
      type: 'POST',
      url: 'http://localhost/GP/ALternate/file.php',
      crossDomain: true,
      data: '{"l":2}',
      dataType: 'json',
      success: function(responseData, textStatus, jqXHR) {
          var value = responseData.someKey;
      alert(value);
    //document.getElementById('w').innerHTML = value.d;
          },
      error: function (responseData, textStatus, errorThrown) {
          alert('POST failed.');
      }
  });
  &lt;/script&gt;
  
  &lt;div id ='w'&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is my php [file.php] script at localhost:</p>
  
  <pre><code>&lt;?php
      header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
      header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
      header('Access-Control-Max-Age: 1000');
      header('Access-Control-Allow-Headers: Content-Type');
  
  
   $f= $_GET["l"]; 
  
   echo "{'d' : '".$f."'}";
  
  
  ?&gt; 
  </code></pre>