0.0.7 • Published 6 years ago
dom-form-submit v0.0.7
DOM-Form-Submit
Utility build or use form and submit using provided data. This library will intelligently reuse the same form and perform minimal manipulations for optimum performance.
Installation
Npm
npm install dom-form-submit
Example
var submit = require('dom-form-submit');
// Submit form with data (create or use existing form) with callback to run after submit
submit(
{a: 'b', c: 'd'},
{id: 'my-form-id', name: 'my-form-name'},
function(submittedForm) {} // callback with form element
);
// Submit an existing form.
submit({a: 'b', c: 'd'}, {
method: 'POST',
form: document.getElementById('my-form')
});
// Basically empty form submit
submit();
API Options / Defaults.
{
method: 'GET',
enctype: 'application/x-www-form-urlencoded',
target: '_self'
}
Please feel free to create a PR!