PHP - Check if is AJAX request

<?php function IsAjax() { $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; if(!$isAjax) { $user_error = 'Access denied - not an AJAX request...'; trigger_error($user_error, E_USER_ERROR); } } ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.