WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Difference between revisions of "Function Reference/wp send json"

m (Changelog: Link version 3.5)
(Include more information about the function)
Line 1: Line 1:
 
== Description ==
 
== Description ==
   
What it does
+
Send a JSON response back to an Ajax request.
   
 
== Usage ==
 
== Usage ==
   
%%% <?php ?> %%%
+
%%% <?php wp_send_json( $response ) ?> %%%
   
 
== Parameters ==
 
== Parameters ==
  +
{{Parameter|$response|mixed|Variable (usually an array or object) to encode as JSON, then print and die.}}
   
 
== Examples ==
 
== Examples ==
Line 19: Line 20:
 
== Source File ==
 
== Source File ==
   
<tt> </tt> is located in {{Trac| }}
+
<tt>wp_send_json()</tt> is located in {{Trac|wp-includes/functions/php}}
   
 
== Related ==
 
== Related ==

Revision as of 17:59, 12 December 2012

Description

Send a JSON response back to an Ajax request.

Usage

 <?php wp_send_json$response ?> 

Parameters

$response
(mixed) (required) Variable (usually an array or object) to encode as JSON, then print and die.
Default: None

Examples

Default Usage

Change Log

Source File

wp_send_json() is located in wp-includes/functions/php

Related