title: Abort php script execution when jquery ajax is aborted
body: <p>I'm looking to stop the execution of a PHP script when the jQuery <code>$.post</code> is aborted by <code>abort()</code>. Basically whenever a user changes any input field the <code>$.post</code> should hit the <code>test.php</code>. If a second input is changed before the first request returns, the <code>$.post</code> is aborted and a new one is sent. I want PHP to stop execution when this happens.</p>
  <p>According to <a href="http://www.php.net/manual/en/features.connection-handling.php" rel="nofollow noreferrer">PHP manual on connection handlnig</a> :</p>
  <blockquote>
  <p>connection_status() return ABORTED state ONLY if the client disconnects gracefully (with STOP button). In this case the browser send the RST TCP packet that notify PHP the connection is closed.</p>
  </blockquote>
  <p>Is there anyway to send the <code>RST TCP</code> when using <code>xhr.abort()</code>?</p>
  <p>To make sure I've tested this in the <code>test.php</code> file. Theoretically if the script is stopped the files should have different sizes and number of lines in them. But they're all the same. So the script is not aborting.</p>
  <p>jQuery main file:</p>
  <pre><code>var xhr = false;
  $('input').on('change', function(){
      if(xhr){
          xhr.abort();
      }
  
      xhr = $.post('/test.php', this.value, function(b64){
          xhr = false;
      });
  });
  </code></pre>
  <p>PHP test.php</p>
  <pre><code>ignore_user_abort(false);
  file_put_contents($_SERVER['DOCUMENT_ROOT'].'/test/test1.log', &quot;1\r\n&quot;,  FILE_APPEND);
  sleep(1);
  file_put_contents($_SERVER['DOCUMENT_ROOT'].'/test/test2.log', &quot;1\r\n&quot;,  FILE_APPEND);
  sleep(1);
  file_put_contents($_SERVER['DOCUMENT_ROOT'].'/test/test3.log', &quot;1\r\n&quot;,  FILE_APPEND);
  sleep(1);
  file_put_contents($_SERVER['DOCUMENT_ROOT'].'/test/test4.log', &quot;1\r\n&quot;,  FILE_APPEND);
  </code></pre>