2010-10-27 16:17:00 -04:00
|
|
|
/*!
|
2021-02-23 14:45:04 -05:00
|
|
|
* jQuery serializeObject - v0.2-wp - 1/20/2010
|
2010-10-27 16:17:00 -04:00
|
|
|
* http://benalman.com/projects/jquery-misc-plugins/
|
2021-02-23 14:45:04 -05:00
|
|
|
*
|
2010-10-27 16:17:00 -04:00
|
|
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
|
|
|
* Dual licensed under the MIT and GPL licenses.
|
|
|
|
* http://benalman.com/about/license/
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
|
|
|
|
// serializes a form into an (arguably more useful) object.
|
|
|
|
|
|
|
|
(function($,undefined){
|
|
|
|
'$:nomunge'; // Used by YUI compressor.
|
2021-02-23 14:45:04 -05:00
|
|
|
|
2010-10-27 16:17:00 -04:00
|
|
|
$.fn.serializeObject = function(){
|
|
|
|
var obj = {};
|
2021-02-23 14:45:04 -05:00
|
|
|
|
2010-10-27 16:17:00 -04:00
|
|
|
$.each( this.serializeArray(), function(i,o){
|
|
|
|
var n = o.name,
|
|
|
|
v = o.value;
|
2021-02-23 14:45:04 -05:00
|
|
|
|
2010-10-27 16:17:00 -04:00
|
|
|
obj[n] = obj[n] === undefined ? v
|
2021-02-23 14:45:04 -05:00
|
|
|
: Array.isArray( obj[n] ) ? obj[n].concat( v )
|
2010-10-27 16:17:00 -04:00
|
|
|
: [ obj[n], v ];
|
|
|
|
});
|
2021-02-23 14:45:04 -05:00
|
|
|
|
2010-10-27 16:17:00 -04:00
|
|
|
return obj;
|
|
|
|
};
|
2021-02-23 14:45:04 -05:00
|
|
|
|
2010-10-27 16:17:00 -04:00
|
|
|
})(jQuery);
|