| @@ 10058-10092 (lines=35) @@ | ||
| 10055 | ||
| 10056 | // Serialize an array of form elements or a set of |
|
| 10057 | // key/values into a query string |
|
| 10058 | jQuery.param = function( a, traditional ) { |
|
| 10059 | var prefix, |
|
| 10060 | s = [], |
|
| 10061 | add = function( key, value ) { |
|
| 10062 | ||
| 10063 | // If value is a function, invoke it and return its value |
|
| 10064 | value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
|
| 10065 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
| 10066 | }; |
|
| 10067 | ||
| 10068 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
| 10069 | if ( traditional === undefined ) { |
|
| 10070 | traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
| 10071 | } |
|
| 10072 | ||
| 10073 | // If an array was passed in, assume that it is an array of form elements. |
|
| 10074 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
| 10075 | ||
| 10076 | // Serialize the form elements |
|
| 10077 | jQuery.each( a, function() { |
|
| 10078 | add( this.name, this.value ); |
|
| 10079 | } ); |
|
| 10080 | ||
| 10081 | } else { |
|
| 10082 | ||
| 10083 | // If traditional, encode the "old" way (the way 1.3.2 or older |
|
| 10084 | // did it), otherwise encode params recursively. |
|
| 10085 | for ( prefix in a ) { |
|
| 10086 | buildParams( prefix, a[ prefix ], traditional, add ); |
|
| 10087 | } |
|
| 10088 | } |
|
| 10089 | ||
| 10090 | // Return the resulting serialization |
|
| 10091 | return s.join( "&" ).replace( r20, "+" ); |
|
| 10092 | }; |
|
| 10093 | ||
| 10094 | jQuery.fn.extend( { |
|
| 10095 | serialize: function() { |
|
| @@ 8964-8998 (lines=35) @@ | ||
| 8961 | ||
| 8962 | // Serialize an array of form elements or a set of |
|
| 8963 | // key/values into a query string |
|
| 8964 | jQuery.param = function( a, traditional ) { |
|
| 8965 | var prefix, |
|
| 8966 | s = [], |
|
| 8967 | add = function( key, value ) { |
|
| 8968 | ||
| 8969 | // If value is a function, invoke it and return its value |
|
| 8970 | value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
|
| 8971 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
| 8972 | }; |
|
| 8973 | ||
| 8974 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
| 8975 | if ( traditional === undefined ) { |
|
| 8976 | traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
| 8977 | } |
|
| 8978 | ||
| 8979 | // If an array was passed in, assume that it is an array of form elements. |
|
| 8980 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
| 8981 | ||
| 8982 | // Serialize the form elements |
|
| 8983 | jQuery.each( a, function() { |
|
| 8984 | add( this.name, this.value ); |
|
| 8985 | } ); |
|
| 8986 | ||
| 8987 | } else { |
|
| 8988 | ||
| 8989 | // If traditional, encode the "old" way (the way 1.3.2 or older |
|
| 8990 | // did it), otherwise encode params recursively. |
|
| 8991 | for ( prefix in a ) { |
|
| 8992 | buildParams( prefix, a[ prefix ], traditional, add ); |
|
| 8993 | } |
|
| 8994 | } |
|
| 8995 | ||
| 8996 | // Return the resulting serialization |
|
| 8997 | return s.join( "&" ).replace( r20, "+" ); |
|
| 8998 | }; |
|
| 8999 | ||
| 9000 | jQuery.fn.extend( { |
|
| 9001 | serialize: function() { |
|
| @@ 8447-8478 (lines=32) @@ | ||
| 8444 | ||
| 8445 | // Serialize an array of form elements or a set of |
|
| 8446 | // key/values into a query string |
|
| 8447 | jQuery.param = function( a, traditional ) { |
|
| 8448 | var prefix, |
|
| 8449 | s = [], |
|
| 8450 | add = function( key, value ) { |
|
| 8451 | // If value is a function, invoke it and return its value |
|
| 8452 | value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); |
|
| 8453 | s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
|
| 8454 | }; |
|
| 8455 | ||
| 8456 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
|
| 8457 | if ( traditional === undefined ) { |
|
| 8458 | traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; |
|
| 8459 | } |
|
| 8460 | ||
| 8461 | // If an array was passed in, assume that it is an array of form elements. |
|
| 8462 | if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
|
| 8463 | // Serialize the form elements |
|
| 8464 | jQuery.each( a, function() { |
|
| 8465 | add( this.name, this.value ); |
|
| 8466 | }); |
|
| 8467 | ||
| 8468 | } else { |
|
| 8469 | // If traditional, encode the "old" way (the way 1.3.2 or older |
|
| 8470 | // did it), otherwise encode params recursively. |
|
| 8471 | for ( prefix in a ) { |
|
| 8472 | buildParams( prefix, a[ prefix ], traditional, add ); |
|
| 8473 | } |
|
| 8474 | } |
|
| 8475 | ||
| 8476 | // Return the resulting serialization |
|
| 8477 | return s.join( "&" ).replace( r20, "+" ); |
|
| 8478 | }; |
|
| 8479 | ||
| 8480 | jQuery.fn.extend({ |
|
| 8481 | serialize: function() { |
|