JSFiddle - React, Tailwind, and code Playground
by osserpse
HTML
<form id='postStatus'>
<input name='somename' type='text' value='someval'/>
</form>
<p>
serializeObject(): <code id="result1"></code>
<br><small><a href="http://stackoverflow.com/questions/17488660/difference-between-serialize-and-serializeobject-jquery">This is not a core jQuery function, more here...</a></small>
</p>
<p>
serialize(): <code id="result2"></code>
<br><small><a href="https://api.jquery.com/serialize/">https://api.jquery.com/serialize/</a></small>
</p>
<p>
serializeArray(): <code id="result3"></code>
<br>
<small><a href="https://api.jquery.com/serializeArray/">https://api.jquery.com/serializeArray/</a></small>
</p>
<pre id="result2"></pre>
<pre id="result3"></pre>
JavaScript
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
var v = $("#postStatus").serializeObject();
$('#result1').text(v)
$('#result2').text($("#postStatus").serialize());
$('#result3').text($("#postStatus").serializeArray());