title: How can I get form data with JavaScript/jQuery?
body: <p>Is there a simple, one-line way to get the data of a form as it would be if it was to be submitted in the classic HTML-only way?</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;form&gt;
      &lt;input type="radio" name="foo" value="1" checked="checked" /&gt;
      &lt;input type="radio" name="foo" value="0" /&gt;
      &lt;input name="bar" value="xxx" /&gt;
      &lt;select name="this"&gt;
          &lt;option value="hi" selected="selected"&gt;Hi&lt;/option&gt;
          &lt;option value="ho"&gt;Ho&lt;/option&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>{
      "foo": "1",
      "bar": "xxx",
      "this": "hi"
  }
  </code></pre>
  
  <p>Something like this is too simple, since it does not (correctly) include textareas, selects, radio buttons and checkboxes:</p>
  
  <pre><code>$("#form input").each(function () {
      data[theFieldName] = theFieldValue;
  });
  </code></pre>