Serializing Forms To JSON Objects jQuery - Download Serializing Forms To JSON Objects - jQuery serializeObject

Download Serializing Forms To JSON Objects – jQuery serializeObject

Posted on

This time I will share jQuery Plugin and tutorial about Serializing Forms To JSON Objects – jQuery serializeObject, hope it will help you in programming stack.

Serializing Forms To JSON Objects jQuery - Download Serializing Forms To JSON Objects - jQuery serializeObject
File Size: 10.7 KB
Views Total: 4681
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

The serializeObject provides an additional method for jQuery that has the ability to serialize your form values to complex JSON objects.

How to use it:

1. Download and include the minified version of the jQuery serializeObject plugin after jQuery.

1 <script src="//code.jquery.com/jquer.min.js"></script>
2 <script src="jquery.serializeObject.min.js"></script>

2. Note that your form fields must have name attribute as these:

1 <input type="text" name="username">
2 <select name="education">
3   <option value="Jr.High">Jr.High</option>
4   <option value="HighSchool">HighSchool</option>
5   <option value="College">College</option>
6 </select>
7 ...

3. Create a container to display the serialized form data.

1 <pre id="result">
2 </pre>

4. The JavaScript to output the serialized data in the ‘result’ container.

1 $('form').submit(function() {
2   $('#result').text(JSON.stringify($('form').serializeObject()));
3   return false;
4 });

This awesome jQuery plugin is developed by hongymagic. For more Advanced Usages, please check the demo page or visit the official website.

source : jqueryscript.net