Skip to content
💾 Utility to easily submit forms in the browser.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client
server
.gitignore
README.md
package.json

README.md

Submit-Form

Utility build a form and submit it automatically. This library will intelegently reuse the same form and perform minimal manipulations for optimum performance.

This module can be required in node (for isomorphic apps) but will error on use.

Installation

Npm

npm install submit-form

Example

var submit = require("submit-form");

// Submit a hidden form.
submit("/my-form", {
	method: "POST",
	body: { a: 1 }
});

// Submit a different form.
submit("/my-other-form", {
	method: "POST",
	body: document.getElementById("my-form")
});

// Basically the same as clicking a link.
submit("/my-page");

// Alternatively you can submit to the current page.
submit({
	method: "POST",
	body: document.getElementById("my-form")
});

API Options / Defaults.

{
	method: "GET",
	body: {}, // The body will be flattened and inputs created for each value.
	enctype: "application/x-www-form-urlencoded",
	target: "_self"
}

Contributions

  • Use gulp to run tests.

Please feel free to create a PR!

You can’t perform that action at this time.