public static function isAjax()
    {
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
            && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
        ) {
            return true;

        } elseif (self::isCli()) {
            return true;

        } elseif (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            foreach ($headers as $key => $value) {
                if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') {
                    return true;
                }
            }

        } elseif (isset($_REQUEST['ajax']) && $_REQUEST['ajax']) {
            return true;

        } elseif (isset($_REQUEST['AJAX']) && $_REQUEST['AJAX']) {
            return true;

        }

        return false;
    }
public static function isAjax()
    {
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])
            && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
        ) {
            return true;

        } elseif (self::isCli()) {
            return true;

        } elseif (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();
            foreach ($headers as $key => $value) {
                if (strtolower($key) == 'x-requested-with' && strtolower($value) == 'xmlhttprequest') {
                    return true;
                }
            }

        } elseif (isset($_REQUEST['ajax']) && $_REQUEST['ajax']) {
            return true;

        } elseif (isset($_REQUEST['AJAX']) && $_REQUEST['AJAX']) {
            return true;

        }

        return false;
    }
public static function isAjax ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) == 'xmlhttprequest' ) { return true ; } elseif ( self :: isCli ( ) ) { return true ; } elseif ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; foreach ( $ headers as $ key => $ value ) { if ( strtolower ( $ key ) == 'x-requested-with' && strtolower ( $ value ) == 'xmlhttprequest' ) { return true ; } } } elseif ( isset ( $ _REQUEST [ 'ajax' ] ) && $ _REQUEST [ 'ajax' ] ) { return true ; } elseif ( isset ( $ _REQUEST [ 'AJAX' ] ) && $ _REQUEST [ 'AJAX' ] ) { return true ; } return false ; }
Check is current HTTP request is ajax
@return  bool
Check is current HTTP request is ajax