| @@ 7597-7627 (lines=31) @@ | ||
| 7594 | ||
| 7595 | // Serialize an array of form elements or a set of |
|
| 7596 | // key/values into a query string |
|
| 7597 | param: function( a, traditional ) { |
|
| 7598 | var s = [], |
|
| 7599 | add = function( key, value ) { |
|
| 7600 | // If value is a function, invoke it and return its value |
|
| 7601 | value = jQuery.isFunction( value ) ? value() : value; |
|
| 7602 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
| 7603 | }; |
|
| 7604 | ||
| 7605 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
| 7606 | if ( traditional === undefined ) { |
|
| 7607 | traditional = jQuery.ajaxSettings.traditional; |
|
| 7608 | } |
|
| 7609 | ||
| 7610 | // If an array was passed in, assume that it is an array of form elements. |
|
| 7611 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
| 7612 | // Serialize the form elements |
|
| 7613 | jQuery.each( a, function() { |
|
| 7614 | add( this.name, this.value ); |
|
| 7615 | }); |
|
| 7616 | ||
| 7617 | } else { |
|
| 7618 | // If traditional, encode the "old" way (the way 1.3.2 or older |
|
| 7619 | // did it), otherwise encode params recursively. |
|
| 7620 | for ( var prefix in a ) { |
|
| 7621 | buildParams( prefix, a[ prefix ], traditional, add ); |
|
| 7622 | } |
|
| 7623 | } |
|
| 7624 | ||
| 7625 | // Return the resulting serialization |
|
| 7626 | return s.join( "&" ).replace( r20, "+" ); |
|
| 7627 | } |
|
| 7628 | }); |
|
| 7629 | ||
| 7630 | function buildParams( prefix, obj, traditional, add ) { |
|
| @@ 6662-6692 (lines=31) @@ | ||
| 6659 | ||
| 6660 | // Serialize an array of form elements or a set of |
|
| 6661 | // key/values into a query string |
|
| 6662 | param: function( a, traditional ) { |
|
| 6663 | var s = [], |
|
| 6664 | add = function( key, value ) { |
|
| 6665 | // If value is a function, invoke it and return its value |
|
| 6666 | value = jQuery.isFunction( value ) ? value() : value; |
|
| 6667 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
| 6668 | }; |
|
| 6669 | ||
| 6670 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
| 6671 | if ( traditional === undefined ) { |
|
| 6672 | traditional = jQuery.ajaxSettings.traditional; |
|
| 6673 | } |
|
| 6674 | ||
| 6675 | // If an array was passed in, assume that it is an array of form elements. |
|
| 6676 | if ( jQuery.isArray( a ) || a.jquery ) { |
|
| 6677 | // Serialize the form elements |
|
| 6678 | jQuery.each( a, function() { |
|
| 6679 | add( this.name, this.value ); |
|
| 6680 | } ); |
|
| 6681 | ||
| 6682 | } else { |
|
| 6683 | // If traditional, encode the "old" way (the way 1.3.2 or older |
|
| 6684 | // did it), otherwise encode params recursively. |
|
| 6685 | for ( var prefix in a ) { |
|
| 6686 | buildParams( prefix, a[ prefix ], traditional, add ); |
|
| 6687 | } |
|
| 6688 | } |
|
| 6689 | ||
| 6690 | // Return the resulting serialization |
|
| 6691 | return s.join( "&" ).replace( r20, "+" ); |
|
| 6692 | } |
|
| 6693 | }); |
|
| 6694 | ||
| 6695 | function buildParams( prefix, obj, traditional, add ) { |
|