title: Ajax request taking too long time
body: <p>Ajax request is taking too long to give response back</p>
  
  <p>Jquery code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready( function() {
      $('#contactForm').on('submit', function(e) {
          e.preventDefault();
  
          $.ajax({
              type:"POST",
              url:"&lt;?php echo site_url;?&gt;includes/listContact.php",
              data:$("#contactForm input").serialize(),//only input
              success: function(response){
  
                      $('#thankMsg').show();
                      $('#hidediv1').hide();
                  }
          });
  
  
      });
  
   });
  &lt;/script&gt;
  </code></pre>
  
  <p>and this is the page which is requested by ajax code:</p>
  
  <pre><code>$file3 = file_get_contents('a.txt', true);
  $data3=json_decode($file3,true);
  $to=$data3['email'];
  $subject="*********************";
  
  // To send HTML mail, the Content-type header must be set
  $headers  = 'MIME-Version: 1.0' . "\r\n";
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  $headers .= 'From:  &lt;'.$to.'&gt;' . "\r\n";
  
  
  
  $message="Hi, &lt;br/&gt;&lt;br/&gt;";
  $message .="*********************** &lt;br/&gt;&lt;br/&gt;";
  foreach($_POST as $key =&gt; $value){
  $message .="&lt;strong&gt;".ucfirst(str_replace('_',' ',$key)).":&lt;/strong&gt;        $value&lt;br/&gt;";
  }
  $message .="&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Thanks&lt;/strong&gt;&lt;br/&gt;";
  
  
  if(mail ("$to", "$subject", "$message", "$headers"))
  {
   echo "done";
  }
  else
  {
   echo "no";
  }
  </code></pre>
  
  <p>Taking almost 10-12 seconds to get the response? I didn't found any problem in this code...as its very simple script and data sent by ajax is only input fields value.</p>
  
  <p>Thanks</p>