Giter Site home page Giter Site logo

ajaxable's Introduction

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

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

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

<script type="text/javascript">
  ajaxable('#myform');
</script>

Listen events

ajaxable('#myform')
.onStart(function(params) {
  // Make stuff before each request, eg. start 'loading animation'
})
.onEnd(function(params) {
  // Make stuff after each request, eg. stop 'loading animation'
})
.onResponse(function(res, params) {
  // Make stuff after on response of each request
})
.onError(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

$ git clone https://github.com/artf/ajaxable.git
$ cd ajaxable

Install it

$ npm i

Start the dev server

$ npm start

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

$ npm run build

API

API Reference here

Testing

Run tests

$ npm test

Run and watch tests

$ npm run test:dev

Compatibility

All modern browsers (IE > 9)

License

MIT

ajaxable's People

Contributors

artf avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.