ibrows/ajaxable

Name: ajaxable

Owner: PwC Experience Center

Description: Make your forms instantly ajaxable

Created: 2017-04-25 10:11:27.0

Updated: 2017-04-25 10:11:29.0

Pushed: 2017-04-25 10:18:37.0

Homepage: https://ajaxable.js.org

Size: 713

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ajaxable

Build Status Coverage Status

This library simply takes the standard HTML forms as an input and make them send requests via AJAX keeping HTML5 validations.

Demo

Installation

Download the file from here, via npm i ajaxable or get it directly from the /dist folder

Usage

Basic

ipt src="path/to/ajaxable.min.js"></script>

m id="myform" method="POST" action="https://se.nd/it/somewhere">
nput name="name" placeholder="Name"/>
nput name="email" placeholder="Email" type="email" required/>
utton>Send</button>
rm>

ipt type="text/javascript">
axable('#myform');
ript>

Listen events

able('#myform')
tart(function(params) {
 Make stuff before each request, eg. start 'loading animation'

nd(function(params) {
 Make stuff after each request, eg. stop 'loading animation'

esponse(function(res, params) {
 Make stuff after on response of each request

rror(function(err, params) {
 Make stuff on errors

The params argument is an object containing additional data about the specific request. For example, el is the form element which made the request and activeRequests indicates how many requests are still pending (useful with multiple forms)

Development

Clone the repository and enter inside the folder

t clone https://github.com/artf/ajaxable.git
 ajaxable

Install it

m i

Start the dev server

m start

Build before the commit. This will also increase the patch level version of the package

m run build
API

API Reference here

Testing

Run tests

m test

Run and watch tests

m run test:dev
Compatibility

All modern browsers (IE > 9)

License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.