I have a form for which I use JQUERY templates, as there can be multiple fields for an attribute. For eg. a user can have multiple phone numbers. So, he can add fields dynamically by pressing the option "add one more number". In this way multiple fields are added but all have the same name.
How should I serialize this kind of form data into a JSON object?
--Thanks in advance
serializing a jquery template form into json using jquery
608 Views Asked by Harshit Agarwal At
2
There are 2 best solutions below
2
Yogesh
On
You can set name attribute for multiple fields to consider it as array. Example is below
<input type="text" name="phone[]"> <input type="text" name="phone[]"> <input type="text" name="phone[]">Now for submitting you can use serializeArray() function to post the data to serverside script
I hope this will work for you
Related Questions in JQUERY
- How to sort these using Javascript or Jquery Most effectively
- Ajax jQuery firing multiple time display event for the same result
- .hover() seems to overwrite .click()
- Check for numeric value with optional commas javascript
- Extending Highmaps Side Effect
- Array appending after each onclick and loop in javascript
- how can i append part of a table based on how many tr it has?
- Play multiple audio files in a slider
- Remove added set of rows
- Access property of an object of type [Model] in JQuery
- AJAX PHP - Reload div after submit
- proengsoft/laravel-jsvalidation ReferenceError: jQuery is not defined
- when a checkbox is checked how to display a different hidden element using javascript
- Get jquery error Uncaught RangeError: Maximum call stack size exceeded
- Removing only the closest thead on table filtering
Related Questions in JSON
- getting undefined while iterating json
- How can I serialize a numpy array while preserving matrix dimensions?
- What is best way to check if any of the property of object is null or empty?
- How to query JSON data according to JSON array's size with Spark SQL?
- Extracting data from json_decode with lat and lng geolocation
- Convert JSON.gz to JSON in node js
- How do I get the type to convert to when deserializing from Jackson
- Escape dot in jquery validate plugin
- Are allOf and properties keywords interchangeable?
- Sort continents by amount of countries
- Is there a data format lighter than json?
- Object of class CS_REST_Wrapper_Result could not be converted to string in CAMPAIGN MONITOR
- How to read JSON data from a web server running PHP and MySQL?
- Parse Nsmutabledictionary and extract value
- Handle empty JSON values in Java
Related Questions in SERIALIZATION
- Saving FileSystemInfo Array to File
- Serializing to disk and deserializing Scala objects using Pickling
- Serializing TypeInfo / Type across .Net Platforms
- How can I send multiple objects over one socket in java?
- Non-intruisive Boost serialization of labelled enums C++
- While Conditions for Deserializing Multiple Objects in Java
- Xml serializing and deserializing with memory stream
- How do I Serialize a JMS Message?
- Serializable class with ISerializable constructor
- Serializing a struct whose definition is not known
- XML Deserializing lists with objects only getting one level
- Using active model serializers for json and csv in Rails?
- Why does Java serialization take up so much space?
- Using Gson to serialize strings with \n in them
- How to covert JSON field name to a Java compatible property name while doing Jackson de-serialisation?
Related Questions in FORMS
- Twitter Bootstrap horizontal form elements on a line
- posting javascript populated form to another php page
- Call a method in a .cs from javascript
- HTML5 form input reacting to enter key
- Why HTML5 required field is not mandatory, if form posted to two different pages using JavaScript?
- django form errors before submit
- PHP Contact Form returning error upon submission
- PHP form validation: Where to plop the code
- javascript check input fields are not blank and check input field length?
- Show success or error messages in Ajax response to Wordpress custom registration form
- Google forms to SMS
- SilverStripe - Multilingual Custom Form Template
- Backbone.Marionette + Rails app redirects after form submission. Why?
- Array not returning default value set over 1,000,000 when using jquery fancy comma script
- How to submit after using ng-repeat, ng-form and ng-submit
Related Questions in JSONTEMPLATE
- If statement syntax with Squarespace JSON templates
- serializing a jquery template form into json using jquery
- Jolt transformation while using IF ELSE map the keys to new keys and also use these replacement for new key value pair
- Using Mustache API to parse Elasticsearch JSON Template requests
- infinite scroll on squarespace get category filter
- How to establish connection between AWS account to outside services or application (which are not on AWS)
- Log4j Json Template Layout Config
- How can I recreate Squarespace's Product Quick View in standard Product View?
- How to make an if statement with JSONT
- squarespace multiple index page styles
- Azure VM Extension provisioning has taken too long to complete
- Issue migrating from PatternLayout to JsonTemplateLayout, Null or empty MDC values does not appear in log
- IllegalAccessError in JsonTemplateLayout in log4j2
- How to create class for dynamic JSON structure in Spring Boot Java
- What is the best way to debug a custom Squarespace JSON-T web application?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can serialize a form with $(form).serialize ()
I'm not sure what the element id has to do with anything, but they should be unique on a page.