Skip to content

Instantly share code, notes, and snippets.

@EvilWolf
Last active September 6, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvilWolf/1b26dd62baf44115c4c0d5e7fb682910 to your computer and use it in GitHub Desktop.
Save EvilWolf/1b26dd62baf44115c4c0d5e7fb682910 to your computer and use it in GitHub Desktop.
Шаблон файла с обработкой ajax данных.
<?php
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php");
if ((empty($_SERVER["HTTP_X_REQUESTED_WITH"]) || strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) != "xmlhttprequest") OR !check_bitrix_sessid()) {
CHTTP::SetStatus('401 Unauthorized');
die("Unauthorized");
}
header('Content-Type: application/json');
$response = ['ERROR' => 'OK'];
if (!empty($response['ERROR'])) {
CHTTP::SetStatus('400 Bad Request');
}
echo json_encode($response);
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment