Created
March 7, 2014 19:49
-
-
Save shalaby/9418559 to your computer and use it in GitHub Desktop.
Detect ajax request in php
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
/* decide what the content should be up here .... */ | |
$content = get_content(); //generic function; | |
/* AJAX check */ | |
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { | |
/* special ajax here */ | |
die($content); | |
} | |
/* not ajax, do more.... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment