S
S
Stanislav2018-03-14 08:30:34
1C-Bitrix
Stanislav, 2018-03-14 08:30:34

What event (hook) can catch sending an AJAX form from a site to Bitrix?

There is a site, it has a callback form that is sent to the backend like this:

function() {
  BX.ajax.submitComponentForm(this, 'comp_17d0ec4a88062c4249d63e84f9ffc380', true)
}

Question: how to catch the sending of this or any form at all on the backend? It would be great if this can be implemented using hooks ("events" in Bitrix terminology), which can be placed somewhere like /bitrix/php_interface/init.php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2018-03-14
@lamo4ok

No way.
That is, you cannot catch sending all forms on the back-end, because each form is in fact not a single request to some address, but a regular POST / GET in an iframe to the same address.
That is, how it works:
1) In JS, you perform a form submission (trigger this function)
2) The function creates an invisible iframe and sets the target of the form to the given iframe
3) This iframe is submitted, and the result that is returned from it is replaced in the form container
The only thing you can do is on JS: it will hang on all forms on the submit event (standard for JS) or on the bitrix onAjaxSuccess (when the form has already been submitted and the result has been received).
Of course, you can catch all GET / POST requests in init.php, but this is already wildness.
PS Edit the component, but do not insert crutches

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question