form-ajax

1.0.2 • Public • Published

FormAjax

npm version

Installation

npm install form-ajax --save

Usage

import FormAjax from 'form-ajax';

const formContainer = document.querySelector('form');
const formAjax = new FormAjax(formContainer, {
    disabledClass: 'disabled', // applied to the form during request
});

form.on('beforeSubmit', form => { // formContainer
    // validate form
    
    if (formIsNotvalid) {
        return false;
    }
    
    return true;
});

form.on('success', data => { // XMLHttpRequest
    console.log(data.response);
    console.log(data.status);
});

form.on('error', data => { // XMLHttpRequest
    console.log(data.response);
    console.log(data.status);
});

Readme

Keywords

Package Sidebar

Install

npm i form-ajax

Weekly Downloads

52

Version

1.0.2

License

ISC

Unpacked Size

3.68 kB

Total Files

5

Last publish

Collaborators

  • bodia