WordPress at a glance

wp_send_json_success() WP 1.0

Send a JSON response back to an Ajax request, indicating success.

  • Since 4.7.0 The $status_code parameter was added.
Works based on: wp_send_json()

No Hooks.


Nothing (null).


wp_send_json_success( $data, $status_code );
Data to encode as JSON, then print and die.
Default: null
The HTTP status code to output.
Default: null

Code of wp_send_json_success: wp-includes/functions.php VER 4.9.8

function wp_send_json_success( $data = null, $status_code = null ) {
	$response = array( 'success' => true );

	if ( isset( $data ) )
		$response['data'] = $data;

	wp_send_json( $response, $status_code );

Related Functions

From tag: AJAX

More from category: Helper Functions

No comments
    Hello, !     Log In . Register