diff options
-rw-r--r-- | src/serialize.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/serialize.js b/src/serialize.js index 9a735fec1..5f9d6c0ae 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -55,14 +55,15 @@ function buildParams( prefix, obj, traditional, add ) { jQuery.param = function( a, traditional ) { var prefix, s = [], - add = function( key, value ) { + add = function( key, valueOrFunction ) { - // If value is a function, invoke it and return its value - value = jQuery.isFunction( value ) ? value() : value; - if ( value == null ) { - value = ""; - } - s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); + // If value is a function, invoke it and use its return value + var value = jQuery.isFunction( valueOrFunction ) ? + valueOrFunction() : + valueOrFunction; + + s[ s.length ] = encodeURIComponent( key ) + "=" + + encodeURIComponent( value == null ? "" : value ); }; // Set traditional to true for jQuery <= 1.3.2 behavior. |