Skip to content

Instantly share code, notes, and snippets.

@madhums
Created October 4, 2012 23:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madhums/3837191 to your computer and use it in GitHub Desktop.
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
Copy link

mpyrev commented Jan 16, 2015

Doesn't work with multiselects.

@shadoath
Copy link

shadoath commented Jan 9, 2020

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