Wrap your regular form with moar ajax.
Wraps good old forms and transforms them into AJAX forms.
npm install compose-remote-form
var RemoteForm = require'compose-remote-form'
More details about each fired "event" below.
// Register single callbacks:RemoteFormon'#formid' 'error'console.log'success!' body// Register multiple callbacks:var formEl = documentquerySelector'#formid'RemoteFormonformElconsole.log'submitting the form...'console.log'success!' bodyconsole.log'error :(' errorconsole.log'complete:' status
Without the need to bind any extra events, you can specify
error functions in your extension of RemoteForm (shown in the example code above.)
Fired before sending the AJAX request. There's no stopping it, but it's useful to notify the user that something is happening, disable buttons/inputs, etc.
It's fired with the superagent request (
Upon success, this is fired with the returned
status and the ajax request
When an error occurs, this event is fired with the original ajax request
xhr object and the
error that the ajax library suffered.
It'll fire in the event of a request not getting through (due to CORS, server down, etc.), a server error (5xx) or a client error (4xx).
complete event is fired at the end of the ajax submission lifecycle,
regardless of success or failure. You might use this event to perform some
cleanup action no matter the end result of a form submission.