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'el: documentquerySelector'form'
More details about each fired "event" below.
RemoteFormextendconsole.log'submitting the form...'console.log'success!' bodyconsole.log'error :(' error
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 be 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).