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


Toastify JS: lightweight toasts in plain JS.
<!-- JavaScript -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js@1/src/toastify.min.js" defer></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js@1/src/toastify.min.css">Set FetchIt.Message:
document.addEventListener('DOMContentLoaded', () => {
FetchIt.Message = {
success(message) {
Toastify({ text: message }).showToast()
},
error(message) {
Toastify({ text: message }).showToast()
},
}
})In a separate file with defer (after the FetchIt script), skip the DOMContentLoaded wrapper:
FetchIt.Message = {
success(message) {
Toastify({ text: message }).showToast()
},
error(message) {
Toastify({ text: message }).showToast()
},
}Form blocks [data-success] and [data-validation-error] work alongside toasts. Skip Message if you only need those blocks. Selectors: documentation.