Is the Request Made with Ajax ?

function is_ajax_request() {
    return ! empty( $_SERVER['HTTP_X_REQUESTED_WITH'] )
        && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) === 'xmlhttprequest';
}