An open API service indexing awesome lists of open source software.

https://github.com/hermanya/ajax-form

Ajax forms made easy, little javascript needed
https://github.com/hermanya/ajax-form

Last synced: 11 months ago
JSON representation

Ajax forms made easy, little javascript needed

Awesome Lists containing this project

README

          

Ajax form
---------
How to use:
- import `` or using your bundler of choice
- add `ajax` attribute on a form
- listen for `success` and `error` events on the form

Other features:
- you may add `contentType="urlencoded"` form attribute, `json` by default
- while in progress form disables submit buttons and has `.submitting` class
- if response body is json, then available through `event.detail.parsedResponseBody`

Example:
```html



log in

var loginForm = document.querySelector('form[action="/login"]');
loginForm.addEventListener('success', function () {
location.hash = 'profile';
})
loginForm.addEventListener('error', function () {
alert('We do not recognize you, double check your credentials.');
})

```