Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery serializeArray() JSON String
    primarykey
    data
    text
    <p>I am trying to serializeArray my form submission in jQuery. I am trying to get a JSON like String or Object. Also if someone can let me know how to pick only those widgets which have a value rather than empty ones that would be perfect. </p> <p>I was in a hurry hence didnt check the syntax and I apologize for it.</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; $(document.ready(function(){ $("#myform").submit(function(){ var mySerialObj = $("#myform").serializeArray(); $.each(mySerialObj,function(indx,idxVal){ //here indx is numeric and idxVal is a String like // [{{"name","name"},{"value","RED"}}] $.each(JSON.parse(idxVal),function(i,v){ //here I am not able to get the thinggy into a // JSON format something like ['name','RED'] }); }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="myform"&gt; &lt;div&gt; &lt;span&gt;What color do you prefer?&lt;/span&gt;&lt;br /&gt; &lt;input type="radio" name="colors" id="red" /&gt;Red&lt;br /&gt; &lt;input type="radio" name="colors" id="blue" /&gt;Blue&lt;br /&gt; &lt;input type="radio" name="colors" id="green" /&gt;Green &lt;/div&gt; &lt;div&gt; &lt;select&gt; &lt;option value="volvo"&gt;Volvo&lt;/option&gt; &lt;option value="saab"&gt;Saab&lt;/option&gt; &lt;option value="mercedes"&gt;Mercedes&lt;/option&gt; &lt;option value="audi"&gt;Audi&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/form&gt; &lt;button type="submit" value="submit" id="sbmt""&gt;submit&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload