
FetchIt
Lightweight AJAX form submission in MODX via the Fetch API on top of FormIt or a custom snippet


FetchIt 1.x was the package for MODX 2 and FetchIt 3.x the package for MODX 3. FetchIt 4 replaces both: one package installs on MODX 2.8 and on MODX 3, over either of the old ones, through Package Manager. System settings and chunks are kept.
Внимание
The FetchIt snippet and plugin are replaced on upgrade, together with the default properties of the snippet, so edits to their code and properties are lost. The snippet calls on your pages need no changes.
$FetchIt = FetchIt::service($modx);. The 1.x way ($modx->getService('fetchit', 'FetchIt', MODX_CORE_PATH . 'components/fetchit/model/')) and the 3.x way ($modx->services->get('FetchIt'), MODX 3 only) return the same object.FetchIt\FetchIt class of 3.x is the same class, and instanceof \FetchIt\FetchIt works. get_class() now returns FetchIt.storeActionProperties() / loadActionProperties() and their 3.x names saveActionProperties() / getActionProperties().@FILE) on both MODX 2 and MODX 3.fetchit.frontend.default.notifier setting no longer loads Notyf; it shows the built-in notifications. Styles for .notyf__toast and calls to new Notyf() need to change, or load Notyf yourself.fetchit:error also fires when a request fails: detail.response is then null and the cause is in detail.error.fields: $_POST, and $_FILES for FetchIt submissions; only $_POST for a normal submission. No GET values and no cookies — it used to get $_REQUEST.fetchit:success can be cancelled: event.preventDefault() keeps the fields filled.method and data-fetchit come last among the attributes of the form tag.fetchit.protection.min_time and fetchit.protection.rate_limit to 0, so the protection does not get in the way of tests.fetchit.captcha for FetchIt forms: FormIt's own AJAX mode is disabled in them.The full list of changes is in the changelog of the component, and the packages of every version are in the GitHub releases.