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.