Created
December 20, 2017 09:42
-
-
Save bozhink/b6625d396b6a3274e8037a939cfaac75 to your computer and use it in GitHub Desktop.
jQuery: serialize form to object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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