Example
<script src="path/to/jQuery.js"></script> <script src="path/to/jQuery-serializer.js"></script> <script> $("form") .serializer(); .on("serializer:data", function (e, formData) { alert(JSON.stringify(formData)); }) ; </script>
When passing the data-convert-to
attribute, the value will be converted in that data type. Currently the following are supported:
string
number
boolean
data-field
is mandatory for the fields which you want to be listed in the JSON object.
Inspect the HTML with the browser developer tools so you can see what's behind this pretty form.