title: PHP Jquery Ajax call throws net::ERR_EMPTY_RESPONSE
body: <p>I have the following JavaScript code in the page. When the ajax call is made, I could see that the browser inspect/debugger section throws <strong>net::ERR_EMPTY_RESPONSE</strong> error. It works fine in localhost environment but throws above error in production.  </p>
  
  <p>In client side code,</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function(){
      $("#identityLinks a").on("click", function(){
      value = $(this).attr("id");
      if(value != "")
      {
          $.ajax({
              url:  "publish/updateUsersData.php",
              type: "POST",
              data: {receiverId: value},
              contentType: "application/x-www-form-urlencoded; charset=UTF-8",
              dataType: "json",
              success: function(data) {
                //alert(data["result"]);
                console.log(data["result"]);
              },
              error: function(xhr, textStatus, errorThrown) {
                 //alert(xhr +" "+ textStatus +" "+errorThrown);
                 console.log(xhr +" "+ textStatus);
              }
          });
      }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>In Server-side code (PHP), I have the following code in <strong>updateUsersData.php</strong>:</p>
  
  <pre><code>&lt;?php
  header('Cache-Control: no-cache, must-revalidate');
  header('Expires: Mon, 01 Jan 1996 00:00:00 GMT');
  header('Content-type: application/json; charset=UTF-8');
  if(isset($_POST["receiverId"]))
  {
      $receiver_id = trim($_POST["receiverId"]);
      $arr = array("result"=&gt;$receiver_id);
      echo json_encode($arr); die();
      break;
  }
  else
  {
      $arr = array("result"=&gt;"No user data received. Error!");
      echo json_encode($arr); die();
      break;
  }
  ?&gt;
  </code></pre>
  
  <p>Do you think it's due to header with Expire calls or a bug in Jquery 1.9.1 version? I didn't find such errors when we were previous versions. Also, this code has not been updated for 5 months and browser errors creep just some time ago. Thanks for all your help and support.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><strong>Status</strong> : This <strong>ISSUE</strong> is not resolved so far. <strong>Jquery AJAX</strong> experts' help needed. Anyone, please promote this question. Also, <strong>CORS</strong> is not responsible for this issue.</p>
  
  <p>When clicking on the console in which the above error occurred, I was directly taken to this line in </p>
  
  <pre><code>JQuery 1.9.1 where console error lines point to:
  
  =&gt; xhr.send( ( s.hasContent &amp;&amp; s.data ) || null );
  
  Also these ones are shown in console error mark:
  
  =&gt; transport.send( requestHeaders, done );
  
  =&gt; ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle 
     || handleObj.handler )
    .apply( matched.elem, args );
  
  =&gt; return typeof jQuery !== core_strundefined &amp;&amp; 
  (!e || jQuery.event.triggered !== e.type) ?
  jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : undefined;
  </code></pre>
  
  <p>Is jquery latest version responsible for this PROVISIONAL HEADERS ARE SHOWN error.</p>