Skip to content

Instantly share code, notes, and snippets.

@madhums
Created October 4, 2012 23:51
Show Gist options
  • Select an option

  • Save madhums/3837191 to your computer and use it in GitHub Desktop.

Select an option

Save madhums/3837191 to your computer and use it in GitHub Desktop.
jquery form serialize hash
var serializeHash = function () {
var attrs = {};
$.each($(this).serializeArray(), function(i, field) {
attrs[field.name] = field.value;
});
return attrs;
};
$.fn.extend({ serializeHash: serializeHash });
// usage
$('form').serializeHash();
@mpyrev

mpyrev commented Jan 16, 2015

Copy link
Copy Markdown

Doesn't work with multiselects.

@shadoath

shadoath commented Jan 9, 2020

Copy link
Copy Markdown

Does work for simpler forms. Thank you good sir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment