如中所述the documentation:
当处理程序完成所有任务时,它需要死亡。如果您正在使用WP_Ajax_Response 或wp\\u send\\u json*函数,这将自动为您处理。如果没有,只需使用WordPresswp_die()
作用
wp_die();
// That\'s all folks!
因此,您需要使用:
$result[\'success\'] = false;
$result[\'string\'] = \'You have not uploaded project file, please upload first!\';
echo json_encode( $result );
wp_die();
或
$result[\'success\'] = false;
$result[\'string\'] = \'You have not uploaded project file, please upload first!\';
wp_send_json( $result );
您还可以使用
success
属性设置为
false
对于您这样的人:
$result = \'You have not uploaded project file, please upload first!\';
wp_send_json_error( $result, 400 );
这将导致如下结果:
{
"success": false,
"data": "You have not uploaded project file, please upload first!"
}