Bug Tracker

Changeset 5703

Show
Ignore:
Timestamp:
05/28/08 02:50:38 (8 months ago)
Author:
aflesler
Message:

jquery ajax: small (misc) improvement to $.param.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/ajax.js

    r5701 r5703  
    487487    // key/values into a query string 
    488488    param: function( a ) { 
    489         var s = []; 
     489        var s = [ ]; 
     490 
     491        function add( key, value ){ 
     492            s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); 
     493        }; 
    490494 
    491495        // If an array was passed in, assume that it is an array 
     
    494498            // Serialize the form elements 
    495499            jQuery.each( a, function(){ 
    496                 s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) ); 
     500                add( this.name, this.value ); 
    497501            }); 
    498502 
     
    504508                if ( a[j] && a[j].constructor == Array ) 
    505509                    jQuery.each( a[j], function(){ 
    506                         s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) ); 
     510                        add( j, this ); 
    507511                    }); 
    508512                else 
    509                     s.push( encodeURIComponent(j) + "=" + encodeURIComponent( jQuery.isFunction(a[j]) ? a[j]() : a[j] ) ); 
     513                    add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); 
    510514 
    511515        // Return the resulting serialization