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


Open a tingle.js dialog after a successful submit.
const successModal = new tingle.modal()
document.addEventListener('fetchit:success', ({ detail: { response: { message } } }) => {
successModal.setContent(message)
successModal.open()
})If you do not need toasts, wire the same modal to success:
const successModal = new tingle.modal()
FetchIt.Message = {
success(message) {
successModal.setContent(message)
successModal.open()
},
error(message) {
// your error UI or toast
console.error(message)
},
}Escape content from message if the response may include HTML.