WP_Ajax_Response::send() WordPress Method

The WP_Ajax_Response::send() method sends an Ajax response to the client. It sets the headers and cookies for the response, and also encodes the data to be sent to the client.

WP_Ajax_Response::send() #

Display XML formatted responses.


Description

Sets the content type header to text/xml.


Top ↑

More Information

This will set the correct content type for the header, output the response xml, then die – ensuring a proper XML response.


Top ↑

Source

File: wp-includes/class-wp-ajax-response.php

	public function send() {
		header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
		echo "<?xml version='1.0' encoding='" . get_option( 'blog_charset' ) . "' standalone='yes'?><wp_ajax>";
		foreach ( (array) $this->responses as $response ) {
			echo $response;
		}
		echo '</wp_ajax>';
		if ( wp_doing_ajax() ) {
			wp_die();
		} else {
			die();
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
2.1.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.