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 error"

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, indicating failure.
   
 
== Usage ==
 
== Usage ==
   
%%% <?php ?> %%%
+
%%% <?php wp_send_json_error( $data ) ?> %%%
   
 
== Parameters ==
 
== Parameters ==
  +
{{Parameter|$data|mixed|Data to encode as JSON, then print and die.|optional|null}}
   
 
== Examples ==
 
== Examples ==
   
 
=== Default Usage ===
 
=== Default Usage ===
  +
  +
== Notes ==
  +
Uses [[Function_Reference/wp send json|wp_send_json()]] to send response.
   
 
== Change Log ==
 
== Change Log ==
Line 19: Line 23:
 
== Source File ==
 
== Source File ==
   
<tt> </tt> is located in {{Trac| }}
+
<tt>wp_send_json_error()</tt> is located in {{Trac|wp-includes/functions.php}}
   
 
== Related ==
 
== Related ==
  +
[[Function_Reference/wp send json|wp_send_json()]], [[Function_Reference/wp send json success|wp_send_json_success()]]

Revision as of 18:05, 12 December 2012

Description

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

Usage

 <?php wp_send_json_error$data ?> 

Parameters

$data
(mixed) (optional) Data to encode as JSON, then print and die.
Default: null

Examples

Default Usage

Notes

Uses wp_send_json() to send response.

Change Log

Source File

wp_send_json_error() is located in wp-includes/functions.php

Related

wp_send_json(), wp_send_json_success()