jrobinsonc
6/2/2016 - 3:33 AM

serializeObject

serializeObject

(function($){'use strict';$.fn.serializeObject=function(){var result={};var extend=function extend(i,element){var node=result[element.name];if(typeof node!=='undefined'&&node!==null){if($.isArray(node)){node.push(element.value)}else{result[element.name]=[node,element.value]}}else{result[element.name]=element.value}};$.each(this.serializeArray(),extend);return result}})(jQuery);
(function ($) {
    'use strict';

    $.fn.serializeObject = function () {

        var result = {};
        var extend = function extend(i, element) {
            var node = result[element.name];

            if (typeof node !== 'undefined' && node !== null) {
                if ($.isArray(node)) {
                    node.push(element.value);
                } else {
                    result[element.name] = [node, element.value];
                }
            } else {
                result[element.name] = element.value;
            }
        };

        $.each(this.serializeArray(), extend);

        return result;
    };
})(jQuery);