wp_doing_ajax() WordPress Function

The wp_doing_ajax() function is used to check whether an AJAX request is currently being processed. This function can be useful for taking specific action when an AJAX request is being made. For example, you could use this function to display a loading indicator while an AJAX request is being processed.

wp_doing_ajax() #

Determines whether the current request is a WordPress Ajax request.


Return

(bool) True if it's a WordPress Ajax request, false otherwise.


Top ↑

Source

File: wp-includes/load.php

function wp_doing_ajax() {
	/**
	 * Filters whether the current request is a WordPress Ajax request.
	 *
	 * @since 4.7.0
	 *
	 * @param bool $wp_doing_ajax Whether the current request is a WordPress Ajax request.
	 */
	return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.