node package manager


Wrap your regular form with moar ajax.

Compose Remote Form

Wraps good old forms and transforms them into AJAX forms.

npm install compose-remote-form
var RemoteForm = require('compose-remote-form')
new RemoteForm({el: document.querySelector('form')})

More details about each fired "event" below.

    console.log('submitting the form...')
    console.log('success!', body)
    console.log('error :(', error)

Without the need to bind any extra events, you can specify beforeSend, success and 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 (req) object.

Upon success, this is fired with the returned body, response status and the ajax request xhr object.

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).