X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fajax-functions.php;h=43a6244afae1dbdce4c4944f18a469a71769d467;hp=6524909cfc6d082e4a9a1276d6a4b00c1ad4afcb;hb=c3db0c416433a946c25ea1ce8d9329c0912a1616;hpb=596c8ab32594401ca84abfbfe35513ddfff31bec diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 6524909cfc..43a6244afa 100644 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -48,6 +48,9 @@ function initAjax () { 'reply_content' => NULL, ); + // Init call-back debug information + $GLOBALS['ajax_callback_function'] = NULL; + // Set content type (mostly JSON) setContentType('application/json'); @@ -66,6 +69,9 @@ function initAjax () { // Setter for AJAX reply content function setAjaxReplyContent ($content) { + // Log message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content()=' . strlen($content)); + // Set it, but with URL encoding $GLOBALS['ajax_reply']['reply_content'] = urlencode(doFinalCompilation($content, FALSE)); } @@ -127,11 +133,20 @@ function processAjaxRequest () { // Send AJAX content function sendAjaxContent () { // Is the status fine or template not found (404)? - if ((getHttpStatus() == '200 OK') || (getHttpStatus() == '404 NOT FOUND')) { + if (isAjaxHttpStatusAccepted()) { // Then output the JSON - outputHtml(json_encode($GLOBALS['ajax_reply'], JSON_FORCE_OBJECT)); + outputHtml(encodeJson($GLOBALS['ajax_reply'])); } // END - if } +// Checks whether the HTTP status is accepted +function isAjaxHttpStatusAccepted () { + // Is it accepted? + $isAccepted = in_array(strtoupper(getHttpStatus()), array('200 OK', '404 NOT FOUND')); + + // Return it + return $isAccepted; +} + // [EOF] ?>