Last active
January 28, 2016 16:59
-
-
Save eugene-ilyin/53df17cb711dd757023c to your computer and use it in GitHub Desktop.
Check that request is AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if current request is AJAX. | |
*/ | |
function MODULE_NAME_is_ajax() { | |
$http_request = isset($_SERVER['HTTP_X_REQUESTED_WITH']) | |
&& strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; | |
// Check ajax in IE. | |
$request_uri = isset($_SERVER['REQUEST_URI']) | |
&& strtolower($_SERVER['REQUEST_URI']) == '/system/ajax'; | |
return $http_request || $request_uri || !empty($_GET['ajax']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment