Skip to content

Instantly share code, notes, and snippets.

@madmis
Created September 30, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madmis/313f99b45b23b506a6e6 to your computer and use it in GitHub Desktop.
Save madmis/313f99b45b23b506a6e6 to your computer and use it in GitHub Desktop.
PHP 7 fastcgi_finish_request - test
<?php
$requestType = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? 'not ajax';
$html = <<<EOL
<html>
<!-- BEGIN HEAD -->
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow" />
<title>HUB - Client List</title>
<script src="//code.jquery.com/jquery-2.1.4.js"></script>
</head>
<body>
<strong>$requestType</strong>
<script>
$(function() {
$.get('index.php?test=test');
});
$(function() {
setTimeout(function() {
// $.get('index.php?test=test');
}, 500);
setTimeout(function() {
// $.get('index.php?test=test');
}, 1500);
});
</script>
</body>
</html>
EOL;
if (!isset($_GET['test'])) {
echo $html;
var_dump($_SERVER);
} else {
echo json_encode(['data' => 'any data']);
}
fastcgi_finish_request();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment