0
|
1 |
/*! |
18
|
2 |
* jQuery serializeObject - v0.2-wp - 1/20/2010 |
0
|
3 |
* http://benalman.com/projects/jquery-misc-plugins/ |
18
|
4 |
* |
0
|
5 |
* Copyright (c) 2010 "Cowboy" Ben Alman |
|
6 |
* Dual licensed under the MIT and GPL licenses. |
|
7 |
* http://benalman.com/about/license/ |
|
8 |
*/ |
|
9 |
|
|
10 |
// Whereas .serializeArray() serializes a form into an array, .serializeObject() |
|
11 |
// serializes a form into an (arguably more useful) object. |
|
12 |
|
|
13 |
(function($,undefined){ |
|
14 |
'$:nomunge'; // Used by YUI compressor. |
18
|
15 |
|
0
|
16 |
$.fn.serializeObject = function(){ |
|
17 |
var obj = {}; |
18
|
18 |
|
0
|
19 |
$.each( this.serializeArray(), function(i,o){ |
|
20 |
var n = o.name, |
|
21 |
v = o.value; |
18
|
22 |
|
0
|
23 |
obj[n] = obj[n] === undefined ? v |
18
|
24 |
: Array.isArray( obj[n] ) ? obj[n].concat( v ) |
0
|
25 |
: [ obj[n], v ]; |
|
26 |
}); |
18
|
27 |
|
0
|
28 |
return obj; |
|
29 |
}; |
18
|
30 |
|
0
|
31 |
})(jQuery); |