Created
June 7, 2011 11:41
-
-
Save admataz/1012073 to your computer and use it in GitHub Desktop.
Function to detect whether the current request is from XMLHTTPREQUEST
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
<? | |
/* | |
* Detect whether the current query is ajax | |
* | |
* TODO: check if this works across browsers and ajax libraries | |
*/ | |
function is_xhr() | |
{ | |
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && | |
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