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


NOTY: toasts in plain JS.
Warning
The author no longer maintains NOTY. The package is marked deprecated.
<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/noty@3.2.0-beta-deprecated/lib/noty.min.js" defer></script>
<!-- CSS -->
<link href="https://cdn.jsdelivr.net/npm/noty@3.2.0-beta-deprecated/lib/noty.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/noty@3.2.0-beta-deprecated/lib/themes/mint.min.css" rel="stylesheet">Set FetchIt.Message:
document.addEventListener('DOMContentLoaded', () => {
FetchIt.Message = {
success(message) {
new Noty({
type: 'success',
text: message
}).show()
},
error(message) {
new Noty({
type: 'error',
text: message
}).show()
},
}
})In a separate file with defer (after the FetchIt script), skip the DOMContentLoaded wrapper:
FetchIt.Message = {
success(message) {
new Noty({
type: 'success',
text: message
}).show()
},
error(message) {
new Noty({
type: 'error',
text: message
}).show()
},
}Form blocks [data-success] and [data-validation-error] work alongside toasts. Skip Message if you only need those blocks. Selectors: documentation.