/** * 判定是否ajax调用 */ public static function is_ajax() { if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { // Typically used to denote AJAX requests $requested_with = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']); } return ($requested_with === 'xmlhttprequest'); }