Skip to content

Instantly share code, notes, and snippets.

@sjordan1975
Created May 8, 2019 23:02
Show Gist options
  • Select an option

  • Save sjordan1975/aa84bbf84818d5858d4d4ad4fd3e872c to your computer and use it in GitHub Desktop.

Select an option

Save sjordan1975/aa84bbf84818d5858d4d4ad4fd3e872c to your computer and use it in GitHub Desktop.
[isAjax Request] Is the incoming request an ajax request #php #ajax
define('__ERROR__', -1);
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
// if this page is not being accessed via AJAX, return error
if (!IS_AJAX){
echo __ERROR__;
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment