X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fajax-functions.php;h=59ad97d18115e41998485789ffaadd02ced519ba;hb=839c74c5882de11b95046f6bca0ea0e02ea139c8;hp=47db96ca0bfdf4bf6d6992bc06064cee0e2fd1a7;hpb=63f159414369b5ea19a8ca75d8cd8033c45d8341;p=mailer.git diff --git a/inc/ajax-functions.php b/inc/ajax-functions.php index 47db96ca0b..59ad97d181 100644 --- a/inc/ajax-functions.php +++ b/inc/ajax-functions.php @@ -66,8 +66,11 @@ 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)); + $GLOBALS['ajax_reply']['reply_content'] = urlencode(doFinalCompilation($content, FALSE)); } /** @@ -76,7 +79,7 @@ function setAjaxReplyContent ($content) { */ function isAjaxRequestLevelValid () { // By default nothing is valid - $isValid = false; + $isValid = FALSE; // Switch on the 'level' value switch (postRequestElement('level')) { @@ -127,11 +130,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] ?>