Skip to content

Instantly share code, notes, and snippets.

@davidkevork
Created July 19, 2015 21:07
Show Gist options
  • Save davidkevork/d68424acb950416a3853 to your computer and use it in GitHub Desktop.
Save davidkevork/d68424acb950416a3853 to your computer and use it in GitHub Desktop.
<?php
/**
* it will detect whether the request is in Ajax or no
*/
function IsAjax()
{
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
// checking $_SERVER['HTTP_X_REQUESTED_WITH'] is exist so no error outputs if it is not set
if (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
return true;
}
} else {
return false;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment