Created
June 22, 2010 20:46
-
-
Save dshaw/449041 to your computer and use it in GitHub Desktop.
$.fn.serializeObject()
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
// Flattens the Array produced by .serializeArray() into an Object | |
// with names as keys and values as their values. | |
(function($) { | |
$.fn.serializeObject = function() { | |
var formData = this.serializeArray(), | |
data = {}; | |
for (var i=0, len=formData.length; i<len; i++) { | |
data[formData[i].name] = formData[i].value; | |
} | |
return data; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment