wp_send_json_success()
wp_send_json_success( mixed $data = null, int $status_c…
wp_send_json_success( mixed $data = null, int $status_code = null )
向Ajax请求发送JSON响应,表示成功。
Send a JSON response back to an Ajax request, indicating success.
目录锚点:#参数#源码#笔记
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $data | (mixed) | 将数据编码为JSON,然后打印并消亡。 |
| $status_code | (int) | 要输出的HTTP状态代码。 |
源码(Source)
/**
* Send a JSON response back to an Ajax request, indicating success.
*
* @since 3.5.0
*
* @param mixed $data Data to encode as JSON, then print and die.
*/
function wp_send_json_success( $data = null ) {
$response = array( 'success' => true );
if ( isset( $data ) )
$response['data'] = $data;
wp_send_json( $response );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.7.0 | wp-includes/functions.php | 10 | 13 |
笔记(Notes)
基本示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!