Skip to content

Instantly share code, notes, and snippets.

@bozhink
Created December 20, 2017 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bozhink/b6625d396b6a3274e8037a939cfaac75 to your computer and use it in GitHub Desktop.
Save bozhink/b6625d396b6a3274e8037a939cfaac75 to your computer and use it in GitHub Desktop.
jQuery: serialize form to object
$.fn.serializeObject = function () {
var i, len, item, object = {}, array = $(this).serializeArray() || [];
len = array.length;
for (i = 0; i < len; i += 1) {
item = array[i];
object[item.name] = item.value;
}
return object;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment