Skip to content

Effortlessly serialize and transmit HTML form data with this powerful package

License

Notifications You must be signed in to change notification settings

GadhiyaAkash/serialize-form-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serialize-form-data

npm version

The serialize-form-data is a plugin that allows you to easily serialize form data and send it to a server using AJAX. The serialize-form-data can handle multiple input types, including text, checkbox, radio, select, and hidden fields. The serialize-form-data also supports nested objects and arrays, as well as custom data attributes.

Installation

To use serialize-form-data, you need to install in your project. You can install the plugin from https://www.npmjs.com/package/serialize-form-data.

Run npm i serialize-form-data

Usage

To use serialize-form-data, you need to have a form element in your HTML page, with a unique id or name attribute. For example: Lets serialize the following html form:

<form id="login-form">
	<input type="text" name="username" value="admin"/>
	<button type="submit">Login</button>
</form>

To serialize the form data and send it to a server using AJAX, you need to call the serialize method on the form element. For example:

import serializeFormData from "serialize-form-data";
var form = document.querySelector('#login-form');

var string = serializeFormData.serialize(form);
// string -> "username=admin"

var objectData = serializeFormData.serialize(form, { hash: true });
// objectData -> { username: 'admin' }

It supports two output formats, url encoded (default) or hash (js objects).

License

The serialize-form-data is licensed under the MIT License. See the LICENSE file for details. (https://github.com/GadhiyaAkash/serialize-form-data/blob/main/LICENSE)

About

Effortlessly serialize and transmit HTML form data with this powerful package

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published