display_ajax_return(): add $pretty parameter
This commit is contained in:
parent
e936064b78
commit
d76c21c526
1 changed files with 4 additions and 2 deletions
|
@ -146,8 +146,10 @@ function display_template($template, $pagetitle=false) {
|
|||
}
|
||||
}
|
||||
|
||||
function display_ajax_return($data) {
|
||||
function display_ajax_return($data=null, $pretty=false) {
|
||||
global $debug_ajax;
|
||||
if (is_null($data))
|
||||
$data = array();
|
||||
if (isset($_SESSION['messages']) && !empty($_SESSION['messages'])) {
|
||||
$data['messages'] = $_SESSION['messages'];
|
||||
unset($_SESSION['messages']);
|
||||
|
@ -159,7 +161,7 @@ function display_ajax_return($data) {
|
|||
if ($debug_ajax)
|
||||
logging('DEBUG',"Ajax Response : ".vardump($data));
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
echo json_encode($data, (($pretty||isset($_REQUEST['pretty']))?JSON_PRETTY_PRINT:0));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue