display_ajax_return(): Return HTTP 400 error code if success==false in retourned data
This commit is contained in:
parent
d76c21c526
commit
6d8812abb5
1 changed files with 4 additions and 0 deletions
|
@ -150,6 +150,10 @@ function display_ajax_return($data=null, $pretty=false) {
|
|||
global $debug_ajax;
|
||||
if (is_null($data))
|
||||
$data = array();
|
||||
// Adjust HTTP error code on unsuccessfull request
|
||||
elseif (isset($data['success']) && !$data['success'] && http_response_code() == 200)
|
||||
http_response_code(400);
|
||||
|
||||
if (isset($_SESSION['messages']) && !empty($_SESSION['messages'])) {
|
||||
$data['messages'] = $_SESSION['messages'];
|
||||
unset($_SESSION['messages']);
|
||||
|
|
Loading…
Reference in a new issue