Forked from i11v/jquery.fn.serializeObject.js
Last active
September 18, 2015 11:36
-
-
Save aonurdemir/d43c69e29a168d16a451 to your computer and use it in GitHub Desktop.
This function extends jQuery by serializeObject method. Argument — form data, returns object.
This file contains 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
;(function ($) { | |
$.fn.serializeObject = function () { | |
var obj = {}, | |
arr = this.serializeArray(); | |
$.each(arr, function () { | |
if (typeof obj[this.name] !== "undefined") { | |
if (!obj[this.name].push) { | |
obj[this.name] = [obj[this.name]]; | |
} | |
obj[this.name].push(this.value || ""); | |
} else { | |
obj[this.name] = this.value || ""; | |
} | |
}); | |
return obj; | |
}; | |
}(jQuery || {})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment