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?(是否有一种简单的单行方式来获取表单数据,就像以经典的纯HTML方式提交那样?)
For example:(例如:)
<form>
<input type="radio" name="foo" value="1" checked="checked" />
<input type="radio" name="foo" value="0" />
<input name="bar" value="xxx" />
<select name="this">
<option value="hi" selected="selected">Hi</option>
<option value="ho">Ho</option>
</form>
Output:(输出:)
{
"foo": "1",
"bar": "xxx",
"this": "hi"
}
Something like this is too simple, since it does not (correctly) include textareas, selects, radio buttons and checkboxes:(这样的事情太简单了,因为它不(正确地)包含文本区域,选择,单选按钮和复选框:)
$("#form input").each(function () {
data[theFieldName] = theFieldValue;
});
ask by Bart van Heukelom translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…