R
R
ragnar_ok2019-08-12 18:54:37
1C-Bitrix
ragnar_ok, 2019-08-12 18:54:37

Why doesn't Bitrix AJAX work?

$APPLICATION->ShowHead();
CJSCore::Init();
$APPLICATION->IncludeComponent(
  "bitrix:news",
  "",
  [
    "AJAX_MODE" => "Y",
    "AJAX_OPTION_ADDITIONAL" => "",
    "AJAX_OPTION_HISTORY" => "Y",
    "AJAX_OPTION_JUMP" => "N",
    "AJAX_OPTION_STYLE" => "N",
    // ... и другие параметры вызова компонента
  ],
  false
);

The AJAX extension of the Bitrix JS library does not work (missing ). The site is multi-site. The Russian site is in the root, while the English site is in /en . Interestingly, the problem manifests itself only on hosting. It is even more interesting that AJAX does NOT work only if the php file with the bitrix:news complex component call and AJAX_MODE enabled is NOT located in the Russian site folder ( / ), but in the English site folder ( /en ). I tried to move this php file with a call to the bitrix:news complex component and enabled AJAX_MODE one level higher to the folder of the Russian-language site ( / ), without changing it. AJAX works.$arParams["AJAX_ID"]

I made a backup and deployed it to BitrixVM. In this case, I can’t repeat the problem - AJAX works, and all links encountered inside the component are converted into AJAX calls. On BitrixVM, I can only reproduce the issue with SEF_MODE enabled.
I got around the problem by setting up the routing (in urlrewrite.php):
$arUrlRewrite = [
 [
   'CONDITION' => '#^/en/folder/#',
   'PATH' => '/folder_en/index.php',
 ],
];

As you can see, now the php file with the bitrix:news complex component call and AJAX_MODE enabled ( /folder_en/index.php ) is now physically located not in /en , but in the root ( / ). Thus everything works!
But the problem is not solved. Maybe there are at least suggestions in which direction to dig?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question