Skip to content

Instantly share code, notes, and snippets.

@mazhar266
Created May 7, 2012 13:05
Show Gist options
  • Save mazhar266/8c4e50f54fbff48f3d2d to your computer and use it in GitHub Desktop.
Save mazhar266/8c4e50f54fbff48f3d2d to your computer and use it in GitHub Desktop.
detect ajax call
<?php
/* 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