Form Async
Form Async is an easy-to-use library that provide acronymous sending on form changes. It's a great solution to preventing data loss when filling out a web form.
Features
- Lightweight (~1.5kb gziped)
- Saves any HTML form element
- Support content editable property
- Full customization
- Retry functionality if ajax request fail
- Send form elements as group of field
- Provide the way to validate changes before sending ajax request
- Heavily tested
Installation
$ npm install form-async
We recommend installing from npm and then using a module bundler such as RequireJS, Webpack or Browserify.
Alternatively, you can use jsdelivr CDN instead of npm.
<!-- 1. Add JS before the closing `</body>` --> <script src="jquery.js"></script> <script src="form-async.js"></script> <!-- 2. Initialize --> <form action="/ajax/account"> <input name="xs_username"> </form> <script> $("form").async(); </script>
Documentation
Read the docs for more details on how to use Form Async.
Callbacks
before
ā pre-request function that can be use to validate data before it is sentsuccess
ā function invoked if the request succeedserror
ā function invoked if the request fails