Skip to content

Instantly share code, notes, and snippets.

@manuel-schoebel
Last active August 29, 2015 14:04
Show Gist options
  • Save manuel-schoebel/fbb1f8bc8a6262a5bf31 to your computer and use it in GitHub Desktop.
Save manuel-schoebel/fbb1f8bc8a6262a5bf31 to your computer and use it in GitHub Desktop.
$.serializeObject
// http://forum.jquery.com/topic/serializeobject
// https://github.com/hongymagic/jQuery.serializeObject/blob/master/jquery.serializeObject.js
$.fn.serializeObject = function() {
var a, o;
o = {};
a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== void 0) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
return o[this.name].push(this.value || '');
} else {
return o[this.name] = this.value || '';
}
});
return o;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment