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
- Host: GitHub
- URL: https://github.com/hermanya/ajax-form
- Owner: Hermanya
- Created: 2016-01-18T02:46:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-20T16:29:04.000Z (over 10 years ago)
- Last Synced: 2025-06-16T09:15:50.069Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://hermanya.github.io/ajax-form/demo
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.');
})
```