Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use php instead to output JSON format to user after submitting the form. <br/></p> <p>Use </p> <pre><code>&lt;?php echo json_encode($_POST); ?&gt; </code></pre> <p>Or if you really need to use jQuery. Use the code below: </p> <pre><code>&lt;form action="" method="post"&gt; first Name:&lt;input type="text" name="first_name"/&gt; &lt;br/&gt; last name:&lt;input type="text" name="last_name"/&gt; &lt;br/&gt; Widget URL:&lt;input type="text" name="zip"/&gt; &lt;br/&gt; Support:&lt;br/&gt; span3:&lt;input type="checkbox" name="subjects" value="bee"/&gt;&lt;br/&gt; span6:&lt;input type="checkbox" name="subjects" value="ms"/&gt;&lt;br/&gt; span12:&lt;input type="checkbox" name="subjects" value="edc"/&gt;&lt;br/&gt; &lt;p&gt;&lt;input type="button" id="btnsubmit" value="submit"/&gt;&lt;/p&gt; &lt;/form&gt; &lt;pre id="json_output"&gt;&lt;/pre&gt; </code></pre> <p>And the jquery code would be :</p> <pre><code>$(document).ready(function(){ var formObject = {}; $('#btnsubmit').click(function(){ var formInputString = $('form').serialize(); var inputParameters = formInputString.split('&amp;'); var nameValues = []; $.each(inputParameters,function(i){ var inputParameter = inputParameters[i].split('='); // 0 - keyName , 1 - keyValue var keyName = inputParameter[0]; var keyValue = inputParameter[1]; if(keyName == 'subjects'){ nameValues.push({ name : keyValue}); formObject[keyName] = nameValues; }else{ formObject[keyName] = keyValue; } }); var myString = JSON.stringify(formObject); $('#json_output').text(myString); }); }); </code></pre> <p>Try it here : <a href="http://jsfiddle.net/XGFg6/" rel="nofollow">http://jsfiddle.net/XGFg6/</a></p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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